Shortcomings of D-Style Fused Operator Overloading

Dom DiSc dominikus at scherkl.de
Sat Jul 8 08:32:00 UTC 2023


On Friday, 7 July 2023 at 17:15:45 UTC, Timon Gehr wrote:
> On 7/7/23 17:49, Ahmet Sait wrote:
>> Seems like the only definition that's useful for implementing 
>> VRP.
>
> VRP is a kind of abstract interpretation, and the natural 
> definition for that is the perfect transformer:
>
> `I op I' = { I op I' | x∈I, x'∈I' }`
>
> I.e., I'd say it is more useful to have three-valued logic 
> operating on `{false}`, `{true}` and `{false,true}`.
>
> Alternatively,
>
> `I <=> I' = { I <=> I' | x∈I, x'∈I' }`
>
> producing a non-empty subset of `{-1,0,1}`.
>
> 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.


More information about the Digitalmars-d mailing list