opCmp, [partial/total/pre]orders, custom floating point types etc.

Fool via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 12 12:43:37 PST 2016


On Tuesday, 12 January 2016 at 20:25:25 UTC, Andrei Alexandrescu 
wrote:
> D uses !(b < a) for a <= b. We can invent notation to disallow 
> that rewrite.
>
> Anyhow the use of <, >, <=, and >= for partially ordered types 
> is bound to be less than smooth. Math papers and books often 
> use other notations (such as rounded or square less-than) to 
> denote operators for partially ordered data, exactly because 
> denoting them with the classic notation may confuse the reader.
>
>
> Andrei

It is perfectly fine to use !(b < a) for a <= b. But as John has 
pointed out this is sensible only if '<=' is total.

Personally, I'm unsure about the best solution for D. I 
understand Walter's argument to 'keep it simple' and do not 
support non-total opCmp. On the other hand it is a bit 
unsatisfactory that one cannot write a custom type that behaves 
like float.


More information about the Digitalmars-d mailing list