Any chance to call Tango as Extended Standard Library
Steven Schveighoffer
schveiguy at yahoo.com
Mon Jan 19 08:27:00 PST 2009
"Andrei Alexandrescu" wrote
> Steven Schveighoffer wrote:
>> While we're on the subject of ditching, can we get rid of
>> foreach_reverse? How hard is it for a range to just have a reverse
>> property:
>>
>> foreach(element; myrange.reverse)
>>
>> Which simply reverses the order of traversal? That also would moot the
>> toe/last/tail/etc. debate ;)
>
> I wish that debate went away. But eliminating toe and retreat would
> require requiring .reverse as a primitive for *all* ranges, which is
> wasteful and repetitive. Instead, a better design is to have ranges (those
> that can) offer toe and retreat primitives such that a generic function
> retro offers backward iteration for any range. In addition, certain
> algorithms (such as the one that reverses a range in place) need to
> manipulate the same range from two ends. Implementing them using .reverse
> and a second range would be more difficult.
I didn't say you couldn't provide toe and retreat in Phobos' ranges (for the
reverse-a-range function). Most likely such an algorithm is not using
foreach and foreach_reverse, but using the functions directly.
My point was, foreach_reverse is an eyesore and a hack, and there really is
no need for it. And what a perfect time to get rid of it, since we are
already changing how foreach works ;)
I realize that this wouldn't really kill the toe debate for Phobos, but at
least it would be a library decision, and not part of the compiler.
-Steve
More information about the Digitalmars-d
mailing list