Missing python-like chaining in D
Dom DiSc
dominikus at scherkl.de
Tue Feb 22 14:42:41 UTC 2022
On Monday, 21 February 2022 at 09:39:58 UTC, Mike Parker wrote:
>>a < b < c, are illegal:
>>
>> ((a < b) ? 1 : 0) < c // C rules (motivated by uniformity)
>> a < b && b < c // Python rules (motivated by math notation)
>>
So we learned, this is NOT the actual python rule, as this would
indeed evaluate b twice. It's something more complicated:
a < b < c
will be lowered to:
auto tmp = b;
a < tmp && tmp < c
and if the chain gets longer, even more complicated:
a > b > c <= d
will be lowered to
auto tmp1 = b;
auto tmp2 = c;
a > tmp1 && tmp1 > tmp2 && tmp2 <= d
and so on.
More information about the Digitalmars-d
mailing list