Missing python-like chaining in D

Abdulhaq alynch4047 at gmail.com
Wed Feb 23 09:49:33 UTC 2022


On Wednesday, 23 February 2022 at 08:56:21 UTC, Dukc wrote:

> 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.

This is right. This thread got me reflecting on why python has 
been so successful in the scientific/engineering/ML domain. I 
don't think GVR was some extraordinary genius, I think he did a 
great job of coming up with a dynamic interpreted language that 
truly was 'turtles all the way down' (use of dicts throughout, 
metaclasses etc.) and managed the expansion of the language 
really well. Then numpy and scipy came along (thanks to a number 
of extremely talented engineers) and python became a very easy 
way to crunch and analyse numbers. The inherent power of python 
made it easy to build various package managers. Tkl and then PyQt 
and wxWidgets made good quality cross-platform GUI apps easy to 
build, and all along GVR prevented python going off the rails. I 
also think the 2 -> 3 transition was well timed and a success, 
contrary to what many bystanders would have you believe.

I would like to see something similar for D (i.e., making it good 
for e.g. general engineering work) but it hasn't worked out like 
that. I'm wondering why that is. Is D being wedded to C both its 
great strength, and its great weakness at the same time?


More information about the Digitalmars-d mailing list