sqrt(2) must go

Jonathan M Davis jmdavisProg at gmx.com
Thu Oct 20 10:28:07 PDT 2011


On Thursday, October 20, 2011 05:13 Don wrote:
> Personally, I'd rather completely eliminate implicit conversions between
> integers and floating point types. But that's just me.

If it's a narrowing conversion, it should require a cast. If it's not, and 
there's no ambguity in the conversion, then I don't see any problem with 
allowing the conversion to be implicit. But then again, I deal with floating 
point values relatively rarely, so maybe there's something that I'm missing.

> My proposal was effectively: if it's ambiguous, choose double. That's all.

Are there _any_ cases in D right now where the compiler doesn't error out on 
ambiguity? In all of the cases that I can think of, D chooses to give an error 
on ambiguity rather than making a choice for you. I'm all for an int literal 
being implicitly converted to a double if the function call is unambiguous and 
there's no loss of precision. But if there's any ambiguity, then it's 
definitely against the D way to have the compiler pick for you.

- Jonathan M Davis


More information about the Digitalmars-d mailing list