More D newb questions.
Walter Bright
newshound1 at digitalmars.com
Mon May 5 16:08:47 PDT 2008
Derek Parnell wrote:
> On Mon, 05 May 2008 14:16:02 -0700, Walter Bright wrote:
>> T ~ T => T[]
> Not quite. Only if T is not an array would this be the expectation.
That means that it's an excessive burden on generic code to have to add
an extra test to ensure that T is an array type else lest unexpectedly
different code gets generated.
What do we do when T's a struct? Look inside the struct to see if it
overloads opIndex? I propose that that's an excessive complication with
little benefit, especially considering there's already unambiguous
syntax to create an array out of values:
[T, T] => T[]
So, we have the unambiguous syntax to create an array out of values, and
another unambiguous syntax to concatenate arrays:
T ~ T => T
and we have an ambiguous syntax to append or prepend values to an array:
T ~ T[] => T[]
T[] ~ T => T[]
I think there is no tern unstoned here.
More information about the Digitalmars-d
mailing list