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

ryuukk_ ryuukk.dev at gmail.com
Tue Apr 25 05:12:39 UTC 2023


On Tuesday, 25 April 2023 at 04:54:43 UTC, Mike Parker wrote:
> I submitted DIP1044, "Enum Type Inference", to Walter and Atila 
> on April 1. I received the final decision from them on April 
> 18. They have decided not to accept this proposal.
>
> https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1044.md
>
> The said the proposal was well done and an interesting read, 
> but found it to be too complex for insufficient benefit. They 
> provided the following list of concerns that led them to their 
> decision:
>
> * Given that D already has `with`, `alias`, and `auto`, it does 
> not seem worthwhile to add a special case for enums.
> * Semantic analysis in D is strictly bottom-up. This proposal 
> would add top-up type inference on top of that. This presents 
> problems in handling function and template overloads, as well 
> as variadic parameter lists.
> * The proposal only allows ETI in some contexts. This is 
> potentially confusing for the programmer, particularly in the 
> presence of mixin templates (which draw symbols from the 
> instantiation context) and function overloads.
> * Symbol tables can get very large. Lookups are done via hash 
> table for max speed, but this will not work for ETI. There may 
> be a very large number of "enums in scope", and each one will 
> have to be searched to resolve a member.
> * ETI is similar to ADL (Argument Dependent Lookup) in C++. 
> Walter implemented ADL in the Digital Mars C++ compiler and is 
> strongly against allowing anything like it in D. He finds it 
> slow and complex, and few people really know how it's going to 
> work.
>
> 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.

Welp, time for me to find a new language then, that's 
unfortunate..


More information about the Digitalmars-d-announce mailing list