Question mark operator proposals
Basile B.
b2.temp at gmx.com
Fri May 12 15:02:26 UTC 2023
On Friday, 12 May 2023 at 13:02:25 UTC, Dadoum wrote:
> There were at some point discussions in the forum about error
> handling and adding a potential question mark operator in D,
Sigh, yes I remember that topic.
This lead to an attempt but unfortunately that did not work.
A few links for those interested to understand what happened:
-
https://forum.dlang.org/post/xtsvjsqyhxtvvhkdytfx@forum.dlang.org
- https://forum.dlang.org/post/ot1q8b$23pt$1@digitalmars.com
- https://github.com/dlang/dmd/pull/7242
After all these years, I find that finally the most usefull
variation is actually the
optional assignment
```d
if (!a)
a = b;
// becomes
a ?= b;
```
faster to lex and parse (9 tokens VS 4), easy to read, but the
main asset is that it is reusable in subexpressions, e.g call
arguments. The optional assignment is my favorite niche
expression lately.
More information about the Digitalmars-d
mailing list