The `with` construct is good, but it could be great
Quirin Schroll
qs.il.paperinik at gmail.com
Wed Jul 20 16:46:10 UTC 2022
The [`with`
statement](https://dlang.org/spec/statement.html#with-statement)
is a good feature. However, a lot of people including me believe
that it lacks potential to be great.
It introduces scope and cannot be used in a declarative scope.
It’s shortcomings are surprisingly similar to C++’s `if
constexpr` that Andrei in [*Design by
Introspection*](https://www.youtube.com/watch?v=k31wZafAMhk&t=1712) considered to be a “fatal mistake”.
Up for discussion, I’d even suggest a no-brace form for `with`
*declarations:*
* `with Symbol:` or `with(Symbol):` (like attributes)
* `with Symbol;` (like `import`)
That implemented, `with` would be a great feature.
Contrary to others, I do not believe that `with` expressions
would be necessary. The main reason `with` expressions are asked
for is because `with` introduces scope.
More information about the Digitalmars-d
mailing list