[pitch] Comparison Reform

+1

What I am arguing for is #2. We have two different expectations and we
need to be explicit about which is being used. Furthermore, I am arguing
that if one of them is going to be the default (and use the ‘==‘ and ‘<‘
symbols), it needs to be the strict equality/total ordering version, since
that is what every other Swift type is modeling, and IEEE is only
applicable to floating point.

Then it's an insoluble problem, because (and for good reasons) there are
those who consider anything other than `.nan != .nan` to be a non-starter.
My attempt to convince people that maybe we could just make that expression
trap instead of giving an answer did not, evidently, win over too many
fans. But I tend to sympathize with the numerics crowd that `.nan == .nan`
would be disastrous for Swift when it comes to numerics. No other (common)
language behaves that way.

···

On Tue, Apr 25, 2017 at 12:45 AM, Jonathan Hull via swift-evolution < swift-evolution@swift.org> wrote:

On Apr 24, 2017, at 9:44 PM, David Waite via swift-evolution < > swift-evolution@swift.org> wrote:
>
> I still think this is a naming conflict more than anything else.
>
> The first expectation is that equatable and comparable provides strict
equality and strict total ordering, and that those are exposed via
operators. The other expectation is that floating point abides by the IEEE
rules which have neither of these, and are exposed via operators.
>
> Either:
> 1. the operators need to do different things in different contexts
> 2. we need different methods/operators to indicate these different
concepts
> 3. Equatable and comparable need to be altered to no longer require
strict equality and strict total ordering (and all generic algorithms based
on equatable/comparable need to be checked that they still work)
> 4. floating point numbers need to explicitly not be equatable/comparable
to prevent their usage in generic algorithms requiring strict behavior.
> 5. We break away from IEEE behavior and provide only strict equality and
strict total ordering
>
> (I tried to sort these roughly in order of feasibility)
>
> Are there any other options?
>
> -DW
>
>> On Apr 24, 2017, at 9:50 PM, Dave Abrahams via swift-evolution < > swift-evolution@swift.org> wrote:
>>
>>
>> on Mon Apr 24 2017, Xiaodi Wu <xiaodi.wu-AT-gmail.com> wrote:
>>
>>> On Mon, Apr 24, 2017 at 9:06 PM, Jonathan Hull via swift-evolution < > >>> swift-evolution@swift.org> wrote:
>>>
>>>> As I am thinking about it more, this means that for == and <
>>>>
>>>> NaN == NaN
>>>> -0 == +0
>>>> +Inf < NaN
>>>>
>>>> Since this would break from IEEE,
>>>
>>> Yeah, as Steve mentioned, it's a huge deal to break from IEEE rules.
>>
>> Allow me to put it even more strongly: I consider reinventing how
>> floating point works to be a massive undertaking comparable to
>> supplanting the Unicode standard with something better. I have no doubt
>> that it could be done by somebody, somewhere, someday, but it would be
>> easy to do something much worse than what IEEE has done, and getting it
>> right would occupy so much of this group's time that we couldn't hope to
>> accomplish anything else, if we even had the expertise—I know I don't!
>> Doing anything in this area that is not firmly rooted in existing
>> standards and practices is not an option I'm willing to pursue.
>>
>> --
>> -Dave
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

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

To be clear, the big downside is the current lack of hardware support. There are apparently some chips in the pipeline, but nothing for Apple platforms that I know of. We are likely to see them first in GPUs and neural network processors (since they allow effective neural networks using only 8-bit values, and the binary representation dramatically simplifies some standard neural network calculations). Most language implementations currently use a backing Int as storage.

That said, I think it is still a worthwhile pursuit, especially for those of us interested in accurate numerical calculations. According to the author, they should also be able to be used interchangeably with Floats in any generic algorithm, though the results would differ (because of the increased accuracy/range). I am still reading to find the details.

If we are interested, I think the first step would be making a third party library...

Thanks,
Jon

···

On Apr 27, 2017, at 4:35 PM, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

There have been a bunch of updates since then (currently under peer review), which deal with implementation on current systems. Reading the new/updated paper now…

Here is a video of the author speaking about some of the general ideas:
https://www.youtube.com/watch?v=aP0Y1uAA-2Y <https://www.youtube.com/watch?v=aP0Y1uAA-2Y&gt;

I doubt we would get rid of Double/Float, but I would love to see it used as a core type in Swift 5. In addition to the increase in accuracy/expressible range, and the simplification of exception handling, apparently the results when used in neural networks are amazing. It also allows you to simplify a bunch of numerical algorithms, because you don’t have to worry about some of the things that go wrong with traditional floats/doubles.

Thanks,
Jon

On Apr 27, 2017, at 2:35 PM, Matthew Johnson <matthew@anandabits.com> wrote:

I mentioned unums on the list about a year ago. Steve Canon replied with some thoughts: https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160509/016889.html\.

On Apr 27, 2017, at 4:26 PM, Jonathan Hull via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I have read it, and it is a truly brilliant work. I would love to see some (or all) of it make it into Swift (most likely Swift 5 or 6). The author is related to a friend of mine, so I can see if he is available to answer questions if there is interest...

On Apr 27, 2017, at 5:14 AM, Björn Forster via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Hi all together,
I was just looking quickly over an article from Wolfram which covers new books covering Mathematica and tripped over this book:

https://www.crcpress.com/The-End-of-Error-Unum-Computing/Gustafson/p/book/9781482239867

From the reviews:
"This book is an extraordinary reinvention of computer arithmetic and elementary numerical methods from the ground up. Unum arithmetic is an extension of floating point in which it is also possible to represent the open intervals between two floating point numbers. This leads to arithmetic that is algebraically much cleaner, without rounding error, overflow underflow, or negative zero, and with clean and consistent treatment of positive and negative infinity and NaN. These changes are not just marginal technical improvements. As the book fully demonstrates, they lead to what can only be described as a radical re-foundation of elementary numerical analysis, with new methods that are free of rounding error, fully parallelizable, fully portable, easier for programmers to master, and often more economical of memory, bandwidth, and power than comparable floating point methods. The book is exceptionally well written and produced and is illustrated on every page with full-color diagrams that perfectly communicate the material. Anyone interested in computer arithmetic or numerical methods must read this book. It is surely destined to be a classic."
—David Jefferson, Center for Advanced Scientific Computing, Lawrence Livermore National Laboratory

I haven't read it myself, as said I stepped just over it, but *MAYBE* it covers the NaN problem in depth and the current state of art how to deal with it.
Maybe someone has free access to an online library (maybe via some university enrollment) and can have a look at it?

- Björn

On Sun, Apr 23, 2017 at 4:40 PM, Chris Lattner via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

> On Apr 22, 2017, at 11:46 PM, David Waite <david@alkaline-solutions.com <mailto:david@alkaline-solutions.com>> wrote:
>
>> On Apr 22, 2017, at 10:58 PM, Chris Lattner via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>>
>> I don’t think that this proposal is acceptable as written. I think it is really bad that abstracting a concrete algorithm would change its behavior so substantially. I don’t care about SNaNs, but I do care about the difference between +0/-1 and secondarily that of NaN handling. It seems really bad that generalizing something like:
>>
>> func doThing(a : Double, b : Double) -> Bool {
>> ….
>> return a != b
>> }
>>
>> to:
>>
>> func doThing<T : FloatingPoint> (a : T, b : T) -> Bool {
>> ….
>> return a != b
>> }
>>
>> would change behavior (e.g. when a is -0.0 and b is +0.0). Likewise, "T : Equatable”.
>
> Did I misunderstand the proposal? If T : FloatingPoint is not included in level 1 comparisons, then you cannot have classes of generic floating point algorithms.

Sorry about that, my mistake, I meant “T: Comparable"

-Chris
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

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

Not to be discouraging, but Swift 5 is wildly ambitious for the inclusion of unum in the stdlib core. Unums will be multiple orders of magnitude slower (and more importantly, less energy efficient) than Float or Double for the foreseeable future, due to the complete lack of hardware support. Hardware can be designed, but no one’s doing it yet, and the timeline from “functional unit is proposed” to “working hardware appears” is around 3-5 years *minimum*. For a large feature without any real precedent, tack on a couple more years. Then you have another 3-5 years before the feature is widely available on a majority of machines in the field.

For that matter, the actual definition of what “unums” are keeps changing. It wouldn’t make sense to put them in the stdlib until the definitions stabilize. Meanwhile we don’t even have bignum integers or complex numbers in the stdlib yet. There’s lots of lower-hanging fruit with a much wider audience to sort out while we wait to see what happens with unum.

If you want to explore unums, I encourage you to do so. I think it would be great for someone to throw a Swift unum library up on GitHub for people to try out. There’s just a whole lot of stuff that should happen before it becomes part of the stdlib.

– Steve

···

On Apr 27, 2017, at 7:35 PM, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

I doubt we would get rid of Double/Float, but I would love to see it used as a core type in Swift 5.

+1

What I am arguing for is #2. We have two different expectations and we need to be explicit about which is being used. Furthermore, I am arguing that if one of them is going to be the default (and use the ‘==‘ and ‘<‘ symbols), it needs to be the strict equality/total ordering version, since that is what every other Swift type is modeling, and IEEE is only applicable to floating point.

Then it's an insoluble problem, because (and for good reasons) there are those who consider anything other than `.nan != .nan` to be a non-starter. My attempt to convince people that maybe we could just make that expression trap instead of giving an answer did not, evidently, win over too many fans. But I tend to sympathize with the numerics crowd that `.nan == .nan` would be disastrous for Swift when it comes to numerics. No other (common) language behaves that way.

Java’s solution is to only support comparison operators for native types like floats and doubles, and to have the IEEE behavior for these types. The java.lang.Comparable interface does not expose operators, and thus does not have a naming conflict. The Comparable implementation for Float has strict total ordering, while ‘<‘ has IEEE behavior.

So I think a sixth option I didn’t propose before. If we were pre Swift 3 it would possibly be the more feasible one:

6. Do not define Equatable/Comparable in terms of the existing operators, and do not expose existing operators based on Equatable/Comparable. Instead, Equatable/Comparable define methods or new operators based on strict equality/total ordering. Conformance to some other sub-protocol like StrictlyEquatable/StrictlyComparable is used to opt into exposing operators based on implementing strict equality and total ordering.

This would mean that Equatable/Comparable generic algorithms are forced to always use total ordering algorithms without the chance of having a conflict with floating point operators - because the naming no longer conflicts.

-DW

···

On Apr 24, 2017, at 11:52 PM, Xiaodi Wu <xiaodi.wu@gmail.com> wrote:
On Tue, Apr 25, 2017 at 12:45 AM, Jonathan Hull via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

> On Apr 24, 2017, at 9:44 PM, David Waite via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>
> I still think this is a naming conflict more than anything else.
>
> The first expectation is that equatable and comparable provides strict equality and strict total ordering, and that those are exposed via operators. The other expectation is that floating point abides by the IEEE rules which have neither of these, and are exposed via operators.
>
> Either:
> 1. the operators need to do different things in different contexts
> 2. we need different methods/operators to indicate these different concepts
> 3. Equatable and comparable need to be altered to no longer require strict equality and strict total ordering (and all generic algorithms based on equatable/comparable need to be checked that they still work)
> 4. floating point numbers need to explicitly not be equatable/comparable to prevent their usage in generic algorithms requiring strict behavior.
> 5. We break away from IEEE behavior and provide only strict equality and strict total ordering
>
> (I tried to sort these roughly in order of feasibility)
>
> Are there any other options?
>
> -DW
>
>> On Apr 24, 2017, at 9:50 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>>
>>
>> on Mon Apr 24 2017, Xiaodi Wu <xiaodi.wu-AT-gmail.com <http://xiaodi.wu-at-gmail.com/&gt;&gt; wrote:
>>
>>> On Mon, Apr 24, 2017 at 9:06 PM, Jonathan Hull via swift-evolution < > >>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>>>
>>>> As I am thinking about it more, this means that for == and <
>>>>
>>>> NaN == NaN
>>>> -0 == +0
>>>> +Inf < NaN
>>>>
>>>> Since this would break from IEEE,
>>>
>>> Yeah, as Steve mentioned, it's a huge deal to break from IEEE rules.
>>
>> Allow me to put it even more strongly: I consider reinventing how
>> floating point works to be a massive undertaking comparable to
>> supplanting the Unicode standard with something better. I have no doubt
>> that it could be done by somebody, somewhere, someday, but it would be
>> easy to do something much worse than what IEEE has done, and getting it
>> right would occupy so much of this group's time that we couldn't hope to
>> accomplish anything else, if we even had the expertise—I know I don't!
>> Doing anything in this area that is not firmly rooted in existing
>> standards and practices is not an option I'm willing to pursue.
>>
>> --
>> -Dave
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

Agreed. I think the first step if we are interested in unums is to make a 3rd party library. (There are apparently chips already in the pipeline, but it won’t affect iOS or Macs, which are the main targets for Swift.)

That said, whether the implementation is based on unums or not, I would really like to see Swift 5/6 move towards having a core floating point type which abstracts away most of the legacy issues. It is crazy to me that we are continuing to bake-in issues based on the limitations of 1980’s tech.

Ideally, there would be a “Float” or “Decimal" type that would Just Work™ for typical / everyday calculations involving decimals (as an analog to Int which just works for integer calculations, but doesn’t guarantee a specific precision), and then various specific formats for people who need specific guarantees (like IEEE conformance or a specific precision). This would replace things like CGFloat and most uses of Float/Double. It should be abstract enough that we could change the internal implementation as needed (or even to have various implementations ala CGFloat). It should not even mess with things like NaN and infinity, leaving those concepts to the specific formats (and using optionals, trapping, or swift error handling when operations can fail).

Thanks,
Jon

···

On Apr 27, 2017, at 5:46 PM, Stephen Canon <scanon@apple.com> wrote:

On Apr 27, 2017, at 7:35 PM, Jonathan Hull via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I doubt we would get rid of Double/Float, but I would love to see it used as a core type in Swift 5.

Not to be discouraging, but Swift 5 is wildly ambitious for the inclusion of unum in the stdlib core. Unums will be multiple orders of magnitude slower (and more importantly, less energy efficient) than Float or Double for the foreseeable future, due to the complete lack of hardware support. Hardware can be designed, but no one’s doing it yet, and the timeline from “functional unit is proposed” to “working hardware appears” is around 3-5 years *minimum*. For a large feature without any real precedent, tack on a couple more years. Then you have another 3-5 years before the feature is widely available on a majority of machines in the field.

For that matter, the actual definition of what “unums” are keeps changing. It wouldn’t make sense to put them in the stdlib until the definitions stabilize. Meanwhile we don’t even have bignum integers or complex numbers in the stdlib yet. There’s lots of lower-hanging fruit with a much wider audience to sort out while we wait to see what happens with unum.

If you want to explore unums, I encourage you to do so. I think it would be great for someone to throw a Swift unum library up on GitHub for people to try out. There’s just a whole lot of stuff that should happen before it becomes part of the stdlib.

– Steve

To be clear, the big downside is the current lack of hardware support. There are apparently some chips in the pipeline, but nothing for Apple platforms that I know of.

Synergy between HW and SW... fully custom ARMv8 cores... wink wink... nudge nudge ;). Maybe if they become super important for Swift there is an economic advantage for their own chips to push for them (Desktop and MacBook are more of an issue and depend on a whole other set of factors to happen).

···

Sent from my iPhone

On 28 Apr 2017, at 01:51, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

We are likely to see them first in GPUs and neural network processors (since they allow effective neural networks using only 8-bit values, and the binary representation dramatically simplifies some standard neural network calculations). Most language implementations currently use a backing Int as storage.

That said, I think it is still a worthwhile pursuit, especially for those of us interested in accurate numerical calculations. According to the author, they should also be able to be used interchangeably with Floats in any generic algorithm, though the results would differ (because of the increased accuracy/range). I am still reading to find the details.

If we are interested, I think the first step would be making a third party library...

Thanks,
Jon

On Apr 27, 2017, at 4:35 PM, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

There have been a bunch of updates since then (currently under peer review), which deal with implementation on current systems. Reading the new/updated paper now…

Here is a video of the author speaking about some of the general ideas:
https://www.youtube.com/watch?v=aP0Y1uAA-2Y

I doubt we would get rid of Double/Float, but I would love to see it used as a core type in Swift 5. In addition to the increase in accuracy/expressible range, and the simplification of exception handling, apparently the results when used in neural networks are amazing. It also allows you to simplify a bunch of numerical algorithms, because you don’t have to worry about some of the things that go wrong with traditional floats/doubles.

Thanks,
Jon

On Apr 27, 2017, at 2:35 PM, Matthew Johnson <matthew@anandabits.com> wrote:

I mentioned unums on the list about a year ago. Steve Canon replied with some thoughts: https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160509/016889.html\.

On Apr 27, 2017, at 4:26 PM, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

I have read it, and it is a truly brilliant work. I would love to see some (or all) of it make it into Swift (most likely Swift 5 or 6). The author is related to a friend of mine, so I can see if he is available to answer questions if there is interest...

On Apr 27, 2017, at 5:14 AM, Björn Forster via swift-evolution <swift-evolution@swift.org> wrote:

Hi all together,
I was just looking quickly over an article from Wolfram which covers new books covering Mathematica and tripped over this book:

https://www.crcpress.com/The-End-of-Error-Unum-Computing/Gustafson/p/book/9781482239867

From the reviews:
"This book is an extraordinary reinvention of computer arithmetic and elementary numerical methods from the ground up. Unum arithmetic is an extension of floating point in which it is also possible to represent the open intervals between two floating point numbers. This leads to arithmetic that is algebraically much cleaner, without rounding error, overflow underflow, or negative zero, and with clean and consistent treatment of positive and negative infinity and NaN. These changes are not just marginal technical improvements. As the book fully demonstrates, they lead to what can only be described as a radical re-foundation of elementary numerical analysis, with new methods that are free of rounding error, fully parallelizable, fully portable, easier for programmers to master, and often more economical of memory, bandwidth, and power than comparable floating point methods. The book is exceptionally well written and produced and is illustrated on every page with full-color diagrams that perfectly communicate the material. Anyone interested in computer arithmetic or numerical methods must read this book. It is surely destined to be a classic."
—David Jefferson, Center for Advanced Scientific Computing, Lawrence Livermore National Laboratory

I haven't read it myself, as said I stepped just over it, but *MAYBE* it covers the NaN problem in depth and the current state of art how to deal with it.
Maybe someone has free access to an online library (maybe via some university enrollment) and can have a look at it?

- Björn

On Sun, Apr 23, 2017 at 4:40 PM, Chris Lattner via swift-evolution <swift-evolution@swift.org> wrote:

> On Apr 22, 2017, at 11:46 PM, David Waite <david@alkaline-solutions.com> wrote:
>
>> On Apr 22, 2017, at 10:58 PM, Chris Lattner via swift-evolution <swift-evolution@swift.org> wrote:
>>
>> I don’t think that this proposal is acceptable as written. I think it is really bad that abstracting a concrete algorithm would change its behavior so substantially. I don’t care about SNaNs, but I do care about the difference between +0/-1 and secondarily that of NaN handling. It seems really bad that generalizing something like:
>>
>> func doThing(a : Double, b : Double) -> Bool {
>> ….
>> return a != b
>> }
>>
>> to:
>>
>> func doThing<T : FloatingPoint> (a : T, b : T) -> Bool {
>> ….
>> return a != b
>> }
>>
>> would change behavior (e.g. when a is -0.0 and b is +0.0). Likewise, "T : Equatable”.
>
> Did I misunderstand the proposal? If T : FloatingPoint is not included in level 1 comparisons, then you cannot have classes of generic floating point algorithms.

Sorry about that, my mistake, I meant “T: Comparable"

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

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

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

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

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

+1

What I am arguing for is #2. We have two different expectations and we
need to be explicit about which is being used. Furthermore, I am arguing
that if one of them is going to be the default (and use the ‘==‘ and ‘<‘
symbols), it needs to be the strict equality/total ordering version, since
that is what every other Swift type is modeling, and IEEE is only
applicable to floating point.

Then it's an insoluble problem, because (and for good reasons) there are
those who consider anything other than `.nan != .nan` to be a non-starter.
My attempt to convince people that maybe we could just make that expression
trap instead of giving an answer did not, evidently, win over too many
fans. But I tend to sympathize with the numerics crowd that `.nan == .nan`
would be disastrous for Swift when it comes to numerics. No other (common)
language behaves that way.

Java’s solution is to only support comparison operators for native types
like floats and doubles, and to have the IEEE behavior for these types. The
java.lang.Comparable interface does not expose operators, and thus does not
have a naming conflict. The Comparable implementation for Float has strict
total ordering, while ‘<‘ has IEEE behavior.

So I think a sixth option I didn’t propose before. If we were pre Swift 3
it would possibly be the more feasible one:

6. Do not define Equatable/Comparable in terms of the existing operators,
and do not expose existing operators based on Equatable/Comparable.
Instead, Equatable/Comparable define methods or new operators based on
strict equality/total ordering. Conformance to some other sub-protocol
like StrictlyEquatable/StrictlyComparable is used to opt into exposing
operators based on implementing strict equality and total ordering.

That's a neat idea. If Comparable only vended the spaceship, then there
would be no clash. Then you provide another protocol (which I think would
be nicely called Ordered, but StrictlyComparable is what you're calling it
here), which gives back operators like < but requires a total order. The
migration path would indeed be difficult.

This would mean that Equatable/Comparable generic algorithms are forced to

···

On Tue, Apr 25, 2017 at 3:12 AM, David Waite <david@alkaline-solutions.com> wrote:

On Apr 24, 2017, at 11:52 PM, Xiaodi Wu <xiaodi.wu@gmail.com> wrote:
On Tue, Apr 25, 2017 at 12:45 AM, Jonathan Hull via swift-evolution < > swift-evolution@swift.org> wrote:
always use total ordering algorithms without the chance of having a
conflict with floating point operators - because the naming no longer
conflicts.

-DW

> On Apr 24, 2017, at 9:44 PM, David Waite via swift-evolution < >> swift-evolution@swift.org> wrote:

>
> I still think this is a naming conflict more than anything else.
>
> The first expectation is that equatable and comparable provides strict
equality and strict total ordering, and that those are exposed via
operators. The other expectation is that floating point abides by the IEEE
rules which have neither of these, and are exposed via operators.
>
> Either:
> 1. the operators need to do different things in different contexts
> 2. we need different methods/operators to indicate these different
concepts
> 3. Equatable and comparable need to be altered to no longer require
strict equality and strict total ordering (and all generic algorithms based
on equatable/comparable need to be checked that they still work)
> 4. floating point numbers need to explicitly not be
equatable/comparable to prevent their usage in generic algorithms requiring
strict behavior.
> 5. We break away from IEEE behavior and provide only strict equality
and strict total ordering
>
> (I tried to sort these roughly in order of feasibility)
>
> Are there any other options?
>
> -DW
>
>> On Apr 24, 2017, at 9:50 PM, Dave Abrahams via swift-evolution < >> swift-evolution@swift.org> wrote:
>>
>>
>> on Mon Apr 24 2017, Xiaodi Wu <xiaodi.wu-AT-gmail.com >> <http://xiaodi.wu-at-gmail.com/&gt;&gt; wrote:
>>
>>> On Mon, Apr 24, 2017 at 9:06 PM, Jonathan Hull via swift-evolution < >> >>> swift-evolution@swift.org> wrote:
>>>
>>>> As I am thinking about it more, this means that for == and <
>>>>
>>>> NaN == NaN
>>>> -0 == +0
>>>> +Inf < NaN
>>>>
>>>> Since this would break from IEEE,
>>>
>>> Yeah, as Steve mentioned, it's a huge deal to break from IEEE rules.
>>
>> Allow me to put it even more strongly: I consider reinventing how
>> floating point works to be a massive undertaking comparable to
>> supplanting the Unicode standard with something better. I have no
doubt
>> that it could be done by somebody, somewhere, someday, but it would be
>> easy to do something much worse than what IEEE has done, and getting it
>> right would occupy so much of this group's time that we couldn't hope
to
>> accomplish anything else, if we even had the expertise—I know I don't!
>> Doing anything in this area that is not firmly rooted in existing
>> standards and practices is not an option I'm willing to pursue.
>>
>> --
>> -Dave
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

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