Range with lookaround

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 2 11:05:57 PST 2017


On 3/2/17 7:51 AM, qznc wrote:
> On Thursday, 2 March 2017 at 01:44:19 UTC, Andrei Alexandrescu wrote:
>> May be worth discussing in here:
>> https://issues.dlang.org/show_bug.cgi?id=17238 -- Andrei
>
> I don't understand the use case. PR #5153 seems to be about getting the
> last element, not about some lookahead. When I think about lookahead, I
> always think of parsers. If the lexer provides an input range of tokens,
> my recursive descent parser might need 3 tokens lookahead, for example.
> For the lexer input a "push back a character into my input" is more
> convenient.

Yah, parsing would be an obvious application. Others such as 
adjacentFind might also benefit.

> Should it give some performance guarantees? I guess, we don't want to
> refresh the buffers at every popFront, so it would probably be as lazy
> as possible.

Yah, a circular buffer should help here.


Andrei



More information about the Digitalmars-d mailing list