Michel Fortin wrote:
On 2009-04-10 17:25:30 -0400, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> said:
Curiously, I didn't find a need for them in std.algorithm so far. I
only defined sameHead, and that's only to help a little improvement in
the bringToFront algorithm.
I've written a few parsers where I repeat this pattern a lot:
string read(alias consumer)(ref string input)
{
string value = input;
consumer(input);
return value.before(input);
}
And I like very much how it reads: "text before input".
All this done on D1. Perhaps it'd need to be revamped a little for D2.
Here's my implementation if you're interested.
[snip]
Thanks. Arrays aren't a problem, but non-random-access ranges are
problematic. (For arrays a slice could also be taken.) That's why I've
been reluctant - if I make before and after primitives, then anyone
defining a range needs to worry about implementing them.
Andrei