Missing python-like chaining in D

Stanislav Blinov stanislav.blinov at gmail.com
Tue Feb 22 09:00:10 UTC 2022


On Monday, 21 February 2022 at 18:53:16 UTC, Timon Gehr wrote:
> 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)

I do know what it means in math (though wouldn't call it 
"standard"), however, it is exactly because...

> mess.c:4:23: warning: comparisons like ‘X<=Y<=Z’ do not have 
> their mathematical meaning

...that I would not know how to interpret that mess (1 < 2 < 3 < 
4 > 3 == 3), nor would I want to learn if any such rules were to 
be introduced, because if they were, they'd go pretty much 
against established language rules, and not be consistent with 
the rest of the language anyway (as the use of anything that can 
be called "standard math" is, at best, very scarce).

Call it a habit, although I'd say it's more of an allergy to 
error-prone practices.


More information about the Digitalmars-d mailing list