PROPOSAL: Implicit conversions of integer literals to floating point

Don nospam at nospam.com
Thu Dec 30 07:56:21 PST 2010


Manfred_Nowak wrote:
> Don wrote:
> 
>> 0 converts to double using implicit conversions.
> 
> The coder should know this while typing.
> The coder should know about the possible problems while typing.
> 
> Because the coder could have typed `0.0' instead of `0', the coder probably 
> wanted the compile time error you described.

No. People expect sqrt(2) to compile, and to return 1.414....
For example, it works in C and in C++.

The only other possible solution would be to disallow conversions 
integer->floating point. I doubt that would be acceptable.


More information about the Digitalmars-d mailing list