[swift-evolution] [Accepted] SE-0104: Protocol-oriented integers

Max Moiseev moiseev at apple.com
Thu Mar 2 11:34:09 CST 2017


The Magnitude requirement was meant to be just Numeric (which does not refine Comparable), and only due to the lack of recursive constraints was desugared into Equatable and ExpressibleByIntegerLiteral.
Nevin has a very valid point that the very definition of Magnitude is about the ordering of things. FWIW, FloatingPoint defines Magnitude as Comparable (even though I could not find uses for it).
TL;DR: associatedtype Magnitude : Numeric, Comparable seems to be the right thing to do, after all.


> On Mar 2, 2017, at 9:23 AM, Björn Forster via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Hi Joe,
> the point made here is about the magnitude of complex numbers.
> The magnitude of one complex number can be compared to the magnitude of a second number.
> 
> Kind Regards
> 
> 
> 
> 
> On Thu, Mar 2, 2017 at 6:21 PM, Joe Groff <jgroff at apple.com <mailto:jgroff at apple.com>> wrote:
> 
>> On Mar 2, 2017, at 6:22 AM, Björn Forster <bjoern.forster at googlemail.com <mailto:bjoern.forster at googlemail.com>> wrote:
>> 
>> Hello Joe,
>> I wanted to ask kindly if it would be possible that the core team adds to the rationale the design decision behind 
>>   associatedtype Magnitude : Equatable, ExpressibleByIntegerLiteral
>> being not comparable. It was pointed out by several reviewers that it is against all intuition that a scalar is not comparable and therefore pretty much useless.
>> 
>> It would be great if you could add the thoughts of the core team regarding this to the rationale to document the reasons behind it.
> 
> Complex numbers have magnitude, but aren't comparable.
> 
> -Joe
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170302/bcd73b23/attachment.html>


More information about the swift-evolution mailing list