Proposal for SentinelInputRange

Walter Bright newshound2 at digitalmars.com
Thu Feb 28 03:03:15 PST 2013


On 2/28/2013 2:42 AM, deadalnix wrote:
> On Thursday, 28 February 2013 at 10:37:35 UTC, Walter Bright wrote:
>> On 2/27/2013 11:37 PM, deadalnix wrote:
>>> It does check for sentinel in many places (and it has to).
>>
>> No, it doesn't. I suggest examining line 481 of lexer.c. Then examine line 558
>> and 559.
>>
>> https://github.com/D-Programming-Language/dmd/blob/master/src/lexer.c
>
> escapeSequence does check for it.

Note the lookahead is done without checking first. This is the salient point. A 
sentinel means you are guaranteed to always be able to look one character ahead 
without checking.

This is used all over the lexer.

The other InputRange forms do not allow peeking ahead without testing *first*.


More information about the Digitalmars-d mailing list