On Tuesday, July 10, 2012 13:58:50 Andrei Alexandrescu wrote: > On 7/10/12 1:17 PM, Daniel Murphy wrote: > > "Christophe Travert"<[email protected]> wrote in message > > news:[email protected]... > > > >> "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?
I see no problem with makeRange. It seems like a sensible name to me. You're taking a sequence of elements and making a range out of them. - Jonathan M Davis
