On 2009-03-22 05:08:55 -0400, Kagamin <[email protected]> said:

Cristian Vlasceanu Wrote:

I passed a proposal of my own to Walter and Andrei, and that is to have D
coders explicitly state the intent of using a slice with the "ref" keyword;
"ref" is already a legal token in D (at least in 2.0) albeit it is only
valid in the context of a parameter list, or foreach argument list. It is
not legal to say "ref int j = i;" in a declaration, for example. But it is a
trivial change in the parser (I have implemented this change as a proof of
concept / language extension research) to allow ref (just for slices): "ref
int[] s = a[1..2];" other than in parameter and foreach arg lists.

There was another suggestion - to mark arrays: int[] is a slice, int[new] is an array.

I like that better, because the less verbose type is a slice and that's what you need to pass around most of the time.

But I think it'd be even better (perhaps not for .NET compatibility, but for D in general) to just remove the need for having a separate array type. For instance, we could have the GC keep track of the array bounds in addition to the allocated size, allowing it to determine if it can grow a slice in place by checking if the slice points at the end. I'm sure someone has already proposed this at some point.

--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to