PROPOSAL: Implicit conversions of integer literals to floating
Don
nospam at nospam.com
Thu Dec 30 12:13:05 PST 2010
bearophile wrote:
> Don:
>
>> No. People expect sqrt(2) to compile, and to return 1.414....
>
> Then people probably need to use sqrt(2.0) or sqrt(cast(double)2).
I've got a lot of sympathy for the first alternative (absolutely NONE
for the second!). But unfortunately, the language allows sqrt(2) to
compile if there is only a single sqrt function.
We have here a feature which works in some cases, but not in others.
Personally, I'd love to see implicit conversions int<->floating point
completely removed from the language. But I think there'd be an outcry
if that happened. The next best option would be to make the implicit
conversions usable.
>> For example, it works in C and in C++.
>
> And maybe it doesn't work in OCaML.
Yes, but OCaML isn't a C-family language, inheriting C's broken
treatment of literals.
More information about the Digitalmars-d
mailing list