Proposal for SentinelInputRange

monarch_dodra monarchdodra at gmail.com
Thu Feb 28 07:37:37 PST 2013


On Thursday, 28 February 2013 at 15:31:21 UTC, Andrei 
Alexandrescu wrote:
> On 2/28/13 5:54 AM, Walter Bright wrote:
>> On 2/27/2013 11:55 PM, Jonathan M Davis wrote:
>>>> Again, please see how lexer.c works. I assure you, there is 
>>>> no double
>>>> copying going on, nor is there a double test for the 
>>>> terminating 0.
>>>
>>> I know what the lexer does, and remember that it _doesn't_ 
>>> operate on
>>> ranges,
>>> and there are subtle differences between being able to just 
>>> use char* and
>>> trying to handle generic ranges.
>>
>> Hence the need to invent SentinelInputRange.
>
> I don't think the sentinel input range is a blocker for redoing 
> the parser (with ranges) in D. This discussion has probably run 
> its course. The right thing to do at this point is port the 
> lexer and figure what primitives are necessary from its input.
>
> Andrei

An actual sentinel range is trivial to implement, and the 
algorithms that can *actually* truly exploit it are rare.

While I'm not against having such ranges in phobos, I'd just be 
weary to provide too many traits for them, or trying to have 
phobos exploit them either. Ranges have enough primitives as it 
is.

Just provide it with a disclaimer than it will only ever be 
useful for a select class of algorithms (parser), but that the 
optimization opportunity will be ignored by the rest of phobos.


More information about the Digitalmars-d mailing list