Discussion Thread: DIP 1044--Enum Type Inference--Community Review Round 1

Adam D Ruppe destructionator at gmail.com
Sat Nov 19 13:01:20 UTC 2022


On Saturday, 19 November 2022 at 03:46:55 UTC, Walter Bright 
wrote:
> True, but you could also do:
>
> with (MySuperLongType):  // <= note colon
> MySuperLongType flag = ValueA | ValueB | ValueC | ValueD | 
> ValueE | ValueF |
>  ValueG;

Something I do before making a post is to run it through the 
compiler to ensure it actually works like I'm claiming it works. 
You should do this too.

The colon form is only valid outside functions, not inside them*. 
Inside a function, you need to use the {} form.

(btw my experience with the colon form outside functions tends to 
be regret anyway so I very rarely use it anymore anyway.)

* well ok, you can put a nested aggregate inside a function and 
that's kinda still inside a function. but you know what i mean, i 
think the grammar calls it a declaration context vs a statement 
context but i forget the formal words.


More information about the Digitalmars-d mailing list