digitalmars.D - Re: Array literals' default type
- bearophile <bearophileHUGS lycos.com> Oct 08 2009
Andrei Alexandrescu: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. The literal can initialize either double or double, so the question is only what the default should be when "auto" is used.
double is safer and more flexible, so I think that has to be the default. The double is a (very useful) optimization. auto c = [2, 3.14, 6.023e22]; => double double[$] c = [2, 3.14, 6.023e22]; => double Bye, bearophile
Oct 08 2009