> Just wanted to expand on the type tolerances idea with an example:
>
> let a:Float±0.1 = 1234.56
> let b:Float±0.5 = 123.456
>
> let result:Float±0.25 = a + b // Error as b’s tolerance > 0.25
That example is a good motivation for two things I would like to see in Swift:
- Generic value parameters (has been proposed, but lacks traction)
- Inheritance for structs / "newtype"-feature (should have been proposed weeks
ago…)
With both things available, it would be possible to implement your example with
a slightly different syntax:
let a: FloatNumber<tolerance: 0.1> = 1234.56
Better support for plain simple calculations would be really cool — I still
remember how impressed I've been the first time I saw the Scheme-Interpreter
printing a number that filled the whole screen ;-)
Tino
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution