Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
March 01, 2017 Range with lookaround | ||||
---|---|---|---|---|
| ||||
May be worth discussing in here: https://issues.dlang.org/show_bug.cgi?id=17238 -- Andrei |
March 02, 2017 Re: Range with lookaround | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | 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.
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.
|
March 02, 2017 Re: Range with lookaround | ||||
---|---|---|---|---|
| ||||
Posted in reply to qznc | 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 |
March 03, 2017 Re: Range with lookaround | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | 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
//My understanding of the concept, is this correct?
assert(iota(5).lookAhead(1, 2).array ==
[ [0, 1],
[0, 1, 2],
[0, 1, 2, 3],
[1, 2, 3, 4],
[2, 3, 4],
[3, 4],
[4]
]);
I would prefer if the second argument meant length, not distance to look back. So the call equivalent to the one above would be lookAhead(-2, 4).
|
March 03, 2017 Re: Range with lookaround | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dukc | On Friday, 3 March 2017 at 11:22:37 UTC, Dukc wrote: > [snip] correction: > assert(iota(5).lookAhead(1, 2).array == > [ [0, 1], > [0, 1, 2], > [0, 1, 2, 3], > [1, 2, 3, 4], > [2, 3, 4] > ]); |
March 03, 2017 Re: Range with lookaround | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | 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 Almost similar to this: https://github.com/dlang/phobos/pull/4027 Perhaps we should use that as base? |
March 03, 2017 Re: Range with lookaround | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dukc | On Friday, 3 March 2017 at 11:56:26 UTC, Dukc 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
>
> Almost similar to this: https://github.com/dlang/phobos/pull/4027
>
> Perhaps we should use that as base?
My PR even included such a circular buffer until Andrei suggested to move it to a separate PR.
However, I think we are all misunderstanding Andrei. He isn't referring to a buffer here - have a look at the issue.
|
March 03, 2017 Re: Range with lookaround | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dukc | On 3/3/17 6:22 AM, Dukc wrote:
> iota(5).lookAhead(1, 2)
should be iota(5).lookaround!(1, 2)
|
March 03, 2017 Re: Range with lookaround | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dukc | On 3/3/17 6:56 AM, Dukc 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
>
> Almost similar to this: https://github.com/dlang/phobos/pull/4027
>
> Perhaps we should use that as base?
Yes! cc @wilzbach
|
Copyright © 1999-2021 by the D Language Foundation