Did you know; we need this operator!

Quirin Schroll qs.il.paperinik at gmail.com
Wed Sep 18 14:38:00 UTC 2024


On Monday, 16 September 2024 at 08:49:39 UTC, Kagamin wrote:
> Lol, thank you, markdown.
>
> ```
> with(Days){ ... }
> ```
>
> ```
> {
> 	with Days;
> 	...
> }
> ```

By far the most elegant solution. Especially as in most cases, 
the extra scope is either already there or wouldn’t be needed. In 
a switch statement, it can even go before the first case:
```d
switch (day)
{
     with Days;
case Monday:
     …;
     break;
case Tuesday:
     …;
     break;
}
```

Still, I think for `switch` in particular, if a label is a 
qualified identifier `QI` and doesn’t resolve, it should try 
`typeof(SwitchedExpression).QI`. Solves most cases and is 
flexible.


More information about the Digitalmars-d mailing list