Andrei Alexandrescu wrote:
Consider:

auto c = [ 2.71, 3.14, 6.023e22 ];
c ~= 2.21953167;

Should this work? Currently it doesn't because c's type is deduced as double[3].

The literal can initialize either double[3] or double[], so the question is only what the default should be when "auto" is used.


Thoughts?

Andrei

I agree with the others who say immutable(double)[].
Also, I don't understand why type inference is determined only by the first member. When patching your ICE bug 3374 just now I was struck by how simple it would be to determine the tightest type in the array.
auto c = [0, 2.5, 5, 7.5, 10];
--> should be immutable(double)[].
I guess Walter was just worried about how complicated the rules would become? There's clearly no implementation difficulty.

Reply via email to