Michel Fortin Wrote: > On 2010-02-17 04:17:09 -0500, Walter Bright <[email protected]> said: > > > Don wrote: > >> This is for me the last remaining D2 issue. > > > > That would make it difficult to do things like: > > > > int*[] foo(int *p) > > { > > return [p, p + 1]; > > } > > > > as all the elements of the literal would also have to be immutable. I > > think you've made a good case, but there is also this issue. > > One thing I like to do with array literals is use them for appending > several elements at once: > > array ~= [1, a+1, b+1]; > > This way I avoid multiple array appends so it should be faster, but if > that temporary array literal gets allocated on the heap then it's > rather counterproductive for me to use array literals for this. > > Could cases like this, where the array never escape, be allocated on the > stack?
Doesn't this do exactly that now? array ~= 1 ~ (a+1) ~ (b+1); -Steve
