[swift-evolution] [Draft][Proposal] Formalized Ordering

Mark Lacey mark.lacey at apple.com
Fri Jul 22 01:18:55 CDT 2016


> On Jul 21, 2016, at 10:37 PM, Dmitri Gribenko via swift-evolution <swift-evolution at swift.org> wrote:
> 
> On Thu, Jul 21, 2016 at 10:17 PM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>> Robert, the gist is notably vague on this point, so I'm hoping you will
>> clarify. Are you proposing that FloatingPoint will break with IEEE754
>> semantics? What will be the result of `Float.nan == Float.nan`?
>> 
>> (My guess at the sanest outcome is that areSame/Equivalent() and <=> will be
>> totally ordered but FloatingPoint types will override == and the standard
>> comparison operators to maintain IEEE754 semantics, yes?)
> 
> Right, == (and !=, <, >, <=, >=) can be customized with
> domain-specific semantics, and floating point does this.  In addition,
> floating point protocols will list == as a requirement, so generic
> code generic over floating point types will get IEEE 754 semantics
> when using == syntax, but code that only has an Equatable requirement
> will use the total ordering semantics.

I think this needs to be spelled out clearly in the final proposal. Floating-point compares involving NaN are mentioned in the motivation section, but there is no clear connection made to that issue in the proposal or detailed design.

Mark

> 
> Dmitri
> 
> -- 
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list