[swift-evolution] Improve Number Type
dabrahams at apple.com
Wed Jan 6 17:39:08 CST 2016
> On Jan 6, 2016, at 3:32 PM, James Campbell via swift-evolution <swift-evolution at swift.org> wrote:
> There is a number of deficiencies with Swift and Numbers. Especially when trying to be clever with generics.
> - The API exposes built in types like`BuiltIn.Word` as the return type of some APIs but there is no way to use said types.
> - We have a Float and a Float80. Float and Doubles can't be initialised (via init) with anything but Integer values but Float80 can be initialized with both Floating Point and Integer
> - We have a SignedNumberType but no UnsignedNumberType, All the floating points use this protocol, so shouldn't this be NumberType ?
> - SignedIntegerType and UnsignedIntegerType have a way of generically constructing an Int as long as you cast it to the Maximum Int or UInt. But there is no such thing for Floating Point Numbers.
> - We have Float80 and a typealised Float32 and Float64. Why couldn't have triple as an extra type name, as having one true type with a number is confusing ?
> - If all number types could be initilized with all number types, then a lot of the constructors could be in the NumberType protocol.
We’re currently working on improving most of these things. You can see some of our work in progress here:
More information about the swift-evolution