On 2013-02-28 17:43, Walter Bright wrote:
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.



I do not understand... Why make a special type of InputRange when you can achieve exactly that with a normal string with an added extra '\0' at the end and then use it without any calls to empty():

while(1) {
    ...
    popFront();
    switch(front) {
        case '\0': return;
        ...
    }
}

Cstrings are a very special case because we know the terminator beforehand and the check is trivial CPU-wise.

Reply via email to