> On 19. Jun 2017, at 19:58, Stephen Canon <[email protected]> wrote:
> 
>> On Jun 19, 2017, at 11:46 AM, Ted F.A. van Gaalen via swift-evolution 
>> <[email protected] <mailto:[email protected]>> wrote:
>> 
>> var result: Float = 0.0
>> result = float * integer * uint8 +  double   
>> // here, all operands should be implicitly promoted to Double before the 
>> complete expression evaluation.
> 
> You would have this produce different results than:
> 
>       let temp = float * integer * uint8
“temp”  is now a Float
>       result = temp + double
“temp" being implicitly converted to a Double before expression evaluation 
> 
(assuming the var “result” is still the Float declared in my example)
after conversion, the expression would be implicitly, type wise  
float = Float( double + double)

Apart perhaps from small floating point inherent imprecision, I don’t see much 
difference...
am I missing something? 

> That would be extremely surprising to many unsuspecting users.
> 
> Don’t get me wrong; I *really want* implicit promotions (I proposed one 
> scheme for them  way back when Swift was first unveiled publicly). But 
> there’s a lot more subtlety around them than it seems (for example the C and 
> C++ implicit promotion rules can easily be described on a half-sheet of 
> paper, but are the source of *innumerable* bugs). I would rather have no 
> implicit promotions than half-baked implicit promotions.
> 
I C what you mean. yes, implicit conversion can produce unexpected results, yes.
Have to be used either with common sense or a lot of debugging or both :o)
But that’s the case with many programming language features...
(no debuggers in ca 1980, IDEs are pure luxury :o)

TedvG 

> – Steve

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to