Re: opCmp / opEquals do not actually support partial orders

2018-07-19 Thread Simen Kjærås via Digitalmars-d
On Thursday, 19 July 2018 at 10:14:34 UTC, Dominikus Dittes Scherkl wrote: On Wednesday, 18 July 2018 at 17:30:21 UTC, Jonathan M Davis wrote: On Tuesday, July 17, 2018 21:18:12 John Colvin via Digitalmars-d wrote: Just do what std.typecons.Proxy does and return float.nan for the incomparable

Re: opCmp / opEquals do not actually support partial orders

2018-07-19 Thread Dominikus Dittes Scherkl via Digitalmars-d
On Wednesday, 18 July 2018 at 17:49:19 UTC, H. S. Teoh wrote: On Wed, Jul 18, 2018 at 11:30:21AM -0600, Jonathan M Davis via On the other hand, if opCmp is allowed to return a user-defined type, it would solve the problem in a neat way: just define a quaternary type that encapsulates the

Re: opCmp / opEquals do not actually support partial orders

2018-07-19 Thread Dominikus Dittes Scherkl via Digitalmars-d
On Wednesday, 18 July 2018 at 17:30:21 UTC, Jonathan M Davis wrote: On Tuesday, July 17, 2018 21:18:12 John Colvin via Digitalmars-d wrote: Just do what std.typecons.Proxy does and return float.nan for the incomparable case. Since when is that legal? I thought that it was required for opCmp

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 18 July 2018 at 15:13:24 UTC, rikki cattermole wrote: On 19/07/2018 3:03 AM, Ivan Kazmenko wrote: That's by DMD32 on Windows.  (Sorry, my DMD64 broke after upgrading Visual Studio to 2017, and I failed to fix it right now.  Anyway, it's not like x86_64 uses a different set of

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread H. S. Teoh via Digitalmars-d
On Wed, Jul 18, 2018 at 11:30:21AM -0600, Jonathan M Davis via Digitalmars-d wrote: > On Tuesday, July 17, 2018 21:18:12 John Colvin via Digitalmars-d wrote: > > Just do what std.typecons.Proxy does and return float.nan for the > > incomparable case. > > Since when is that legal? I thought that

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, July 17, 2018 21:18:12 John Colvin via Digitalmars-d wrote: > Just do what std.typecons.Proxy does and return float.nan for the > incomparable case. Since when is that legal? I thought that it was required for opCmp to return int. Certainly, the spec implies that it has to be int. The

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread rikki cattermole via Digitalmars-d
On 19/07/2018 3:03 AM, Ivan Kazmenko wrote: That's by DMD32 on Windows.  (Sorry, my DMD64 broke after upgrading Visual Studio to 2017, and I failed to fix it right now.  Anyway, it's not like x86_64 uses a different set of general purpose floating-point hardware, right?) Boy do I ever have

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 18 July 2018 at 14:02:28 UTC, Dominikus Dittes Scherkl wrote: On Wednesday, 18 July 2018 at 13:12:05 UTC, Ivan Kazmenko wrote: Leaving x uninitialized, or using floats, work about the same. No, floats are a whole lot less slow. Are they? Locally, I don't see much difference.

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread Dominikus Dittes Scherkl via Digitalmars-d
On Wednesday, 18 July 2018 at 13:12:05 UTC, Ivan Kazmenko wrote: On Tuesday, 17 July 2018 at 21:18:12 UTC, John Colvin wrote: Just do what std.typecons.Proxy does and return float.nan for the incomparable case. Isn't it slow though on current processors? I just threw together a test

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 17 July 2018 at 21:18:12 UTC, John Colvin wrote: Just do what std.typecons.Proxy does and return float.nan for the incomparable case. Isn't it slow though on current processors? I just threw together a test program. - import std.datetime.stopwatch, std.math, std.stdio;

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread Dominikus Dittes Scherkl via Digitalmars-d
On Tuesday, 17 July 2018 at 21:18:12 UTC, John Colvin wrote: On Tuesday, 17 July 2018 at 18:21:26 UTC, H. S. Teoh wrote: But opCmp turns out to be a tarpit. Here's why: According to the original claim, it should also return 0, for "incomparable". However, this leads to problems:

Re: opCmp / opEquals do not actually support partial orders

2018-07-17 Thread John Colvin via Digitalmars-d
On Tuesday, 17 July 2018 at 18:21:26 UTC, H. S. Teoh wrote: As we know, when opCmp is defined for a user type, then opEquals must also be defined in order for == to work, even though in theory the compiler could translate x==y into x.opCmp(y)==0. In the past, it was argued that this was so

opCmp / opEquals do not actually support partial orders

2018-07-17 Thread H. S. Teoh via Digitalmars-d
As we know, when opCmp is defined for a user type, then opEquals must also be defined in order for == to work, even though in theory the compiler could translate x==y into x.opCmp(y)==0. In the past, it was argued that this was so that partial orders could be made to work, i.e., it could be the