The Expressiveness of D

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Nov 2 07:53:12 PDT 2010


On 11/2/10 8:39 AM, Torarin wrote:
>> // these don't work - why?
>> //  auto b = [new B, new C];
>> //  auto c = { return [1: new B,2: new C]; };
>
> That seems to be just a matter of improving the compiler to make it
> find the common type. I don't think there's anything in the language
> stopping that from working.

Yah, in fact it's a recent addition that it even attempts to find the 
common type. While I was writing TDPL, the first draft mentioned the 
rule then in effect: the literal array type is exclusively determined by 
its first element. The common type rule was only introduced later 
(though in time to fix TDPL), so I'm not surprised there is a glitch in 
there.

Andrei


More information about the Digitalmars-d mailing list