Remove foreach_reverse (was Re: Remove complex and imaginary types?)

Oskar Linde oskar.lindeREM at OVEgmail.com
Fri Jan 11 06:55:48 PST 2008


Matti Niemenmaa wrote:
> bearophile wrote:
>> naryl:
>>> Why don't we remove or at least shorten foreach_reverse too?
>>
>> Removing: -1. It's actually useful (I'd like to see more iteration
>> constructs, not less).
>>
>> Shortening: it's long, so maybe yes, if you/someons find(s) something 
>> better.
>> Do you have some suggestions?
> 
> Ever since the language got the ability to use delegates as the foreach 
> aggregate, there has been no need for foreach_reverse. Ironically 
> enough, that's the same release foreach_reverse was added (0.170).
> 
> Arrays should just have a built-in .reverseview (or whatever) property 
> which returns a delegate for iterating over the array in reverse order.
> 
> And add .sortedview while you're at it.

And the only reason this isn't how its done is because dmd is unable to 
inline functions containing loops, thus foreach_reverse is the faster 
solution for built in arrays.

-- 
Oskar



More information about the Digitalmars-d mailing list