On Sunday 28 November 2010 05:28:45 Andrej Mitrovic wrote: > AFAIK "in" will guarantee you can't change a variable, even when using > arrays, e.g.: > > void foo(in int[] a) { > int[] b; > a[0] = 1; // won't compile > a = b; // won't compile (I think?) > } > > void foo(int[] a) { > int[] b; > a[0] = 1; // compiles, and changes are reflected in the caller > a = b; // compiles, but it doesn't change "a" in the calling code > } > > I don't have DMD on this PC so I haven't tested it.
Well, in is essentially an alias for const scope, so no, you can't change any variables marked in. And since const is transitive, that includes anything that the variable references. So, arrays marked with in are fully const and cannot be altered in any way. - Jonathan M Davis