Missing python-like chaining in D

Dukc ajieskola at gmail.com
Wed Feb 23 08:56:21 UTC 2022


On Tuesday, 22 February 2022 at 10:47:48 UTC, Patrick Schluter 
wrote:
> On Tuesday, 22 February 2022 at 10:28:56 UTC, forkit wrote:
>> On Tuesday, 22 February 2022 at 09:00:10 UTC, Stanislav Blinov 
>> wrote:
>>>
>>> Call it a habit, although I'd say it's more of an allergy to 
>>> error-prone practices.
>>
>> c'mon. all other matters aside...
>>
>> ..you can't deny, that there is beauty in this mess.
>>
>> 1 < 2 < 3 < 4 > 3 == 3
>
> Nope.

I think the stumbling block for a C or D programmer is thinking 
the comparison operators as binary operators, so that `1 < 2 > 1` 
must mean `op!">"(op!"<"(1, 2), 1)` or `op!"<"(1, op!">"(2, 1))` 
or illegal syntax as in D. To understand the Python/Math syntax, 
you must stop this. In them, the three operands are all handled 
in one operation: `op!("<", ">")(1, 2, 1)`. There is no right or 
left associativity.


More information about the Digitalmars-d mailing list