DIP1044---"Enum Type Inference"---Formal Assessment

ryuukk_ ryuukk.dev at gmail.com
Tue Apr 25 20:15:39 UTC 2023


On Tuesday, 25 April 2023 at 18:38:14 UTC, max haughton wrote:
> On Tuesday, 25 April 2023 at 04:54:43 UTC, Mike Parker wrote:
>
> Firstly I think this is the correct decision, certainly for 
> now, probably forever.
>
>> Regarding enums in switch statements, Walter suggested we 
>> could shorten the `with final switch` syntax such that the 
>> `with` is implicitly applied to the type of the switch 
>> variable:
>>
>> ```D
>> auto myEnum = MyEnum.a;
>> with final switch (myEnum) { }
>> ```
>>
>> Alternatively, we could make the `with` implicit for case 
>> statements, but that would break existing code.
>
> What we have at the moment with `with` is, I think perfectly 
> fine.
> The `switch(...) with(...)` pattern is used rather a lot in the 
> SDC codebase
> for example and I think it's very readable.
>
> On the topic of `with` I do think, and have even implemented 
> ;), with expressions do need to happen eventually. The with 
> statement is a little heavy handed for places where these kinds 
> of shorthands are needed locally.

Why you guys focus on "switch"

Who doesn't love writing other than Walter Bright:

```

void set_connected()
{
     network_connect_state = NetworkConnectState.CONNECTED
}

MySuperLongNameFlag flag = MySuperLongNameFlag.A | 
MySuperLongNameFlag.B | MySuperLongNameFlag.C | 
MySuperLongNameFlag.D;


set_flags(MySuperLongNameFlag.A | MySuperLongNameFlag.B | 
MySuperLongNameFlag.C | MySuperLongNameFlag.D)

```


Too hard to implement? oh really? then i suggest trying other 
languages and reading their source code, so you can learn new 
techniques and improve your project

Or perhaps, listen to this person: 
https://github.com/dlang/dmd/pull/14650

He seem talented, he did what you find "too hard" to implement

Being stuck is a good thing if you work, if you don't work, and 
you are stuck, then perhaps is time to reflect on the time spent 
working on being stuck?

I still can't debug my program btw

https://forum.dlang.org/thread/mhqywnoqhoirtruykaqo@forum.dlang.org

So i now understand better, things aren't "hard to implement", 
things are frozen in time, and no will to improve anything, the 
motto is go template yourself! (sumtype)


More information about the Digitalmars-d-announce mailing list