On Thu, 28 Feb 2013 11:43:06 -0500, Walter Bright <newshou...@digitalmars.com> wrote:

On 2/28/2013 6:59 AM, Andrei Alexandrescu wrote:
On 2/28/13 2:37 AM, deadalnix wrote:
I don't see how defining a specific sentinel range here helps.

On first blush I agree. It may as well be a range that by convention is
sentinel-terminated, and there's calls to front and popFront but never to empty.


Consider the following code from lexer.c:

    p++;
    switch (*p)

Written using an InputRange:

    popFront();
    switch (front)

That code is INVALID. This is why a SentinelInputRange is necessary. You can't just use an InputRange in an invalid manner by convention.

Does switch(*p) include a case for 0? If so, wouldn't it be equivalent to say if(empty) /* do stuff that case 0 does */ else switch(front)

-Steve

Reply via email to