Missing python-like chaining in D
Timon Gehr
timon.gehr at gmx.ch
Mon Feb 21 18:53:16 UTC 2022
On 2/21/22 10:48, Stanislav Blinov wrote:
> On Monday, 21 February 2022 at 09:29:56 UTC, forkit wrote:
>> It seems to me, that D is a language where python like chaining would
>> be right at home.
>>
>> writeln(1 < 2 < 3 < 4 > 3 == 3); // true
>>
>
> I've no clue whatsoever how to interpret that mess,
It's standard mathematical notation.
E.g.: https://en.wikipedia.org/wiki/Fence_(mathematics)
> nor do I have any desire of obtaining said clue.
A C compiler with a clue:
mess.c: In function ‘main’:
mess.c:4:23: warning: comparisons like ‘X<=Y<=Z’ do not have their
mathematical meaning [-Wparentheses]
4 | printf("%d", X<=Y<=Z);
| ~^~~
This is why it's disallowed in D (it's basically always an accident).
More information about the Digitalmars-d
mailing list