Why is std.algorithm so complicated to use?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jul 10 10:58:50 PDT 2012
On 7/10/12 1:17 PM, Daniel Murphy wrote:
> "Christophe Travert"<travert at phare.normalesup.org> wrote in message
> news:jthmu8$2s5b$1 at digitalmars.com...
>> "Daniel Murphy" , dans le message (digitalmars.D:171720), a écrit :
>>> Could it be extended to accept multiple values? (sort of like chain)
>>> eg.
>>> foreach(x; makeRange(23, 7, 1990)) // NO allocations!
>>> {
>>> ....
>>> }
>>> I would use this in a lot of places I currently jump through hoops to get
>>> a
>>> static array without allocating.
>>
>> That's a good idea. IMHO, the real solution would be to make an easy way
>> to create static arrays, and slice them when you want a range.
>>
>
> It's not quite the same thing, static arrays are not ranges and once you
> slice them you no longer have a value type, and might be referring to stack
> allocated data. With... this thing, the length/progress is not encoded in
> the type (making it rangeable) but the data _is_ contained in the type,
> making it safe to pass around. The best of both worlds, in some situations.
That does seem good to have. What would be a better name than makeRange?
Andrei
More information about the Digitalmars-d
mailing list