> On Nov 1, 2017, at 9:16 AM, Ben Cohen via swift-dev <swift-dev@swift.org> 
> wrote:
> 
> 
> 
>> On Oct 31, 2017, at 10:11 PM, Chris Lattner via swift-dev 
>> <swift-dev@swift.org> wrote:
>> 
>> On Oct 31, 2017, at 9:07 AM, Stephen Canon via swift-dev 
>> <swift-dev@swift.org> wrote:
>>> [Replying to the thread as a whole]
>>> 
>>> There have been a bunch of suggestions for variants of `==` that either 
>>> trap on NaN or return `Bool?`. I think that these suggestions result from 
>>> people getting tunnel-vision on the idea of “make FloatingPoint equality 
>>> satisfy desired axioms of Equatable / Comparable”. This is misguided. Our 
>>> goal is (should be) to make a language usable by developers; satisfying 
>>> axioms is only useful in as much as they serve that goal.
>>> 
>>> Trapping or returning `Bool?` does not make it easier to write correct 
>>> concrete code, and it does not enable writing generic algorithms that 
>>> operate on Comparable or Equatable. Those are the problems to be solved.
>> 
>> +100.  Swift isn’t the first language to face the problems of floating 
>> point, nor is it the first to try to shoehorn it into a framework like 
>> Equatable.  
> 
> Java and C# do not have this problem with their generic algorithms (albeit 
> possibly because of limitations in their languages that Swift doesn’t have). 
> Swift is setting itself up as a major language with confusing and 
> unjustifiable behavior by comparison. That some other languages are also bad 
> at this doesn’t seem relevant.

C++ has exactly this problem, std::sort on a std::vector<double>.  I haven’t 
seen the world burn down in practice.

-Chris

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to