Infinite range of nullable elements

Roland Hadinger via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 17 06:05:09 PDT 2015


On Friday, 17 July 2015 at 10:19:22 UTC, Márcio Martins wrote:
> On Friday, 17 July 2015 at 07:42:09 UTC, Roland Hadinger wrote:
>> At this moment I'm tempted to implement a function taking a 
>> range of elements E and returning an infinite range of 
>> Nullable!E.
>>
>> [...]
>
> Wouldn't it still require the algorithms to check if an element 
> isNull()?

Naturally. But this check can be done further down the function 
chain,
so all the functions before will see an infinite range.

I'm currently writing a lexer (big loop with two levels of switch 
statements inside) that needs to some looking ahead in multiple 
states. Normally, each of those lookaheads would require a check 
for "end of input". I want to avoid this because of the large 
number of states.



More information about the Digitalmars-d-learn mailing list