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

Dave Abrahams dabrahams at apple.com
Sun Jul 24 15:47:06 CDT 2016


Asking whether zero appears in a sequence that happened to contain a NaN would equally be a precondition violation. I don't think that's an acceptable cliff. The point of NaNs and Infs is that they flow through a multidimensional calculation without disturbing the parts that are still valid, rather than, e.g., 
trapping. 

Sent from my moss-covered three-handled family gradunza

> On Jul 24, 2016, at 10:40 AM, Pyry Jahkola <pyry.jahkola at iki.fi> wrote:
> 
> Pyry Jahkola wrote:
> 
>>> or even to ask whether
>>> someSequence.contains(.nan).  IMO that's not really acceptable.
>> 
>> Not correct. Algorithms like contains(_:) or firstIndex(of:) would use the == operator which is part of the protocol and thus wouldn't call <=> on FloatingPoint types which override the default implementation.
> 
> Oops, spoke too soon. Well, I think it's easy enough to require people to write numbers.contains(where: { $0.isNaN }) in this use case.
> 
> — Pyry


More information about the swift-evolution mailing list