"using the result of a comma expression is not allowed"
Timon Gehr
timon.gehr at gmx.ch
Sun Apr 21 23:32:21 UTC 2024
On 4/21/24 21:16, Don Allen wrote:
> And I think it's bad practice to support a hobbled version of a common construct in anticipation of a use of the same syntax that hasn't happened yet and has been in the pipeline for years.
That is just one part of the rationale (that is probably on top of
people's mind now as there has been some recent movement on tuples).
https://dlang.org/deprecate#Using%20the%20result%20of%20a%20comma%20expression
In any case, I don't understand why you focus on the tuple use case. The
main reason the comma operator was restricted was to avoid accidental
uses. Freeing up the syntax for something that is actually useful is
just a nice side effect.
> I am also not about to re-write my code using lambdas. It's hackish workaround for a defect in the language, in my opinion.
There are many ways to write any given piece of code and the variant
with the comma operator is hardly ever the best one.
> I think this was a mistake in C and a bigger mistake in D, since we know
> more now about language design than when Dennis Ritchie designed C about
> 55 years ago.
One of the things we know now is that comma expressions were a bad
design of syntax. We should probably just have something like `let
statement in expression` expressions instead.
More information about the Digitalmars-d
mailing list