Steven Schveighoffer Wrote: > On Tue, 24 Mar 2009 18:26:16 -0400, Cristian Vlasceanu > <crist...@zerobugs.org> wrote: > > > Back to the slices topic: I agree that my proposed "ref" solution would > > require code changes, but isn't that true for T[new] as well? > > > > Cristian > > > > There is not already a meaning for T[new], it is a syntax error. There is > already a meaning for ref T[]. >
Yes, but the current, existing meaning will be preserved: void f(ref T[] a) { a[13] = 42; // still works as before if "a" is a slice under the hood a = null; // very easy for the compiler to make this work: a.array = null } I thought that your main objection was that, with my proposed change, in code like this: int [] a = ... int [] s = a[0..$]; "s" becomes a full blown copy of a (rather than a slice), and to reinstate the today's semantics the code should be re-written to: ref int [] s = a[0..$]; It is true, but such cases can be worked out in the compiler and we'll have warning messages issued. Thanks, Cristian