[swift-evolution] floating point numbers implicit conversion
xiaodi.wu at gmail.com
Sat Jun 17 22:43:53 CDT 2017
In Swift, all types and all operators are implemented in the standard
library. How do you express the idea that, when you add values of disparate
types T and U, the result should be of the type with greater precision? You
need to be able to spell this somehow.
On Sat, Jun 17, 2017 at 22:39 David Sweeris <davesweeris at mac.com> wrote:
> On Jun 17, 2017, at 16:16, Xiaodi Wu via swift-evolution <
> swift-evolution at swift.org> wrote:
> On Sat, Jun 17, 2017 at 3:21 PM, Ted F.A. van Gaalen <
> tedvgiosdev at gmail.com> wrote:
> As you know, Swift currently does not facilitate implicit conversion
>> which implies that current code (which of course does not contain
>> implicit conversions)
>> will function exactly as it does now,
> That is not implied. Swift has type inference, which means that, with the
> implementation of implicit promotion, the inferred type of certain
> expressions that are legal today will change. For instance, integer
> literals have no type of their own and are inferred to be of some type or
> another based on context. When combined with bitwise operators, the
> presence or absence of overloads that allow heterogeneous operations can
> change the result of code that compiles both before and after the
> implementation of the feature. This is just one example of why implicit
> integer promotion in a strictly typed language with type inference and
> without certain generics features is very hard.
> I'm not sure which generic features you're referring to. Would you (or
> anyone else who knows) mind elaborating?
> - Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution