More D newb questions.

Derek Parnell derek at psych.ward
Mon May 5 15:25:10 PDT 2008


On Mon, 05 May 2008 14:16:02 -0700, Walter Bright wrote:

> Me Here wrote:
>> What elese could 'a' ~ 'b' mean other than char[] tmp = "ab"?
> 
> Let's generalize the issue to be what does:
> 
> 	T ~ T
> 
> mean for any type T? Your argument is that the result should be T[]:
> 
> 	T ~ T => T[]

Not quite. Only if T is not an array would this be the expectation.
 
> Ok. So imagine now that T is S[]:
> 
>          S[] ~ S[] => S[][]
> 
> and we've done away with array concatenation. We could make a special 
> case just for char values (and presumably all basic types), but then 
> we'll find ourselves unable to write generic code.
> 
> 	T ~ T[] => T[]
> 	T[] ~ T => T[]
> 
> has no such ambiguity, and so is supported.

And yet people still think in terms of non-array elements being able to be
be concatenated to form arrays? Is that actually a weird thing?

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list