On Wednesday, 20 October 2021 at 09:47:54 UTC, SealabJaster wrote:
>Just for giggles, without pesky things like breaking changes; rational thinking, logical reasoning behind the changes, etc.
What interesting changes would you make to the language, and what could they possibly look like?
Optional access operator. I tend to write more and more conditional expression with null
as the third operand.
For example I count 93 occurences of the pattern in styx.
Not convinced that this is a very common construct ?
Let's take a look at dmd: 490 occurences.
Example picked from dmd:
StringExp se = ex ? ex.ctfeInterpret().toStringExp() `: null`;"
becomes
StringExp se = ex?.ctfeInterpret().toStringExp();
Please abstraint you to reply to me with remarks like "this can be done using metaprog" ... I know because I did it too a few years ago (using opDispatch
).
This should be built in the language because
- the template solution is necessarily slow to compile
- it is better for tooling