Proposal for SentinelInputRange
Walter Bright
newshound2 at digitalmars.com
Thu Feb 28 08:43:06 PST 2013
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.
More information about the Digitalmars-d
mailing list