DIP1044---"Enum Type Inference"---Formal Assessment
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.
Re: DIP1044---"Enum Type Inference"---Formal Assessment
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..
Re: DIP1044---"Enum Type Inference"---Formal Assessment
On Tuesday, 25 April 2023 at 04:54:43 UTC, Mike Parker wrote: .. Is it okay to use a new keyword `enumswitch` that is equivalent to `with final switch`?
Re: DIP1044---"Enum Type Inference"---Formal Assessment
On Tuesday, 25 April 2023 at 06:41:04 UTC, zjh wrote: Is it okay to use a new keyword `enumswitch` that is equivalent to `with final switch`? If there were an `official restriction` that could simplify `long keywords`, that would be great,like: ```d alias keyword enumswitch=with final switch; ``` Multiple `keywords/@property` can also be simplified (`pure/@ nogc/@ safe/public/...`), but it is best to only allow `official simplification`, otherwise it will mess up the grammar.