"Christophe Travert" <trav...@phare.normalesup.org> wrote in message news:jthmu8$2s5b$1...@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. An easy way to get static arrays would be great too. > > I it were just me, array litterals would be static, and people > should use .dup when they want a a surviving slice. > It used to be like that. Most of the time you don't really want a static array.