> On Jan 6, 2016, at 3:32 PM, James Campbell via swift-evolution > <[email protected]> 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: https://github.com/apple/swift/blob/master/test/Prototypes/Integers.swift.gyb https://github.com/apple/swift/blob/master/test/Prototypes/FloatingPoint.swift -Dave _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
