[swift-evolution] [Proposal draft] Enhanced floating-point protocols

Guillaume Lessard glessard at tffenterprises.com
Fri Apr 15 13:05:50 CDT 2016


> On 15 avr. 2016, at 00:48, Nicola Salmoria via swift-evolution <swift-evolution at swift.org> wrote:
> 
> It might make sense to also have a
> 
> public protocol InvertibleArithmetic : Arithmetic {
>  func inverted() -> Self
> }
> 
> FloatingPoint would conform to this protocol, returning 1/x, while integer types would not.

I don’t see why this is needed; there isn't an AdditivelyInvertible protocol, why have MultiplicativelyInvertible? Are there (schoolbook arithmetic) types for which a terse inversion operation (i.e. `-num` or `1/num`) is not defined? For what it’s worth, “inverse” has so many definitions that “reciprocal” might be better if this must be defined; it has many fewer definitions.

Cheers,
Guillaume Lessard



More information about the swift-evolution mailing list