Shortcomings of D-Style Fused Operator Overloading
Timon Gehr
timon.gehr at gmx.ch
Sat Jul 8 17:22:46 UTC 2023
On 7/8/23 10:32, Dom DiSc wrote:
>>
>> In any case, implementing abstract interpretation as operations on
>> independent abstract elements in the first place is not particularly
>> natural and only works in very special cases such as the interval domain.
>
> You're all aware that opCmp can return a float, with the values 0,1,-1
> and NaN?
> This can be used for intervals very good (returning NaN if the intervals
> overlap, 0 if they are equal and 1 or -1 if they are disjunct).
> Unfortunately float is 32 bit, so pretty much the first thing I did
> after I found D was to implement a 2-bit type with exactly those 4 values.
I am very aware of this. OTOH, you may not be aware that your solution
does not satisfy the OP's constraints.
It cannot do so because D's operator overloading while not enforcing
`a <= b || b < a` still enforces `a <= b <==> a < b || b <= a`, but
while `[x,y] <= [y,z]` holds, neither `[x,y] < [y,z]` nor
`[y,z] <= [x,y]` hold for x<y<z`.
This means the OP is indeed right that it is impossible.
More information about the Digitalmars-d
mailing list