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

Walter Bright newshound2 at digitalmars.com
Fri Nov 18 21:09:41 UTC 2022


What happens in combination with function and template overloading is not 
discussed. For example:

     enum A { a }
     enum B { a }

     void ket(A);
     void ket(B);

     ...
     ket(a);
     ...

That's the simplest case. More complex cases come when there are multiple 
overloaded functions with diverse enum arguments, resulting in an unbounded 
combinatorial problem of which combination of enum members will be selected.

This kind of problem comes up whenever we contemplate adding top-down type 
inference and try to make it work in combination with the current bottom up 
method. It works in trivial cases as shown in the DIP, but the complex ones are 
the problem. (Even worse than the function overloading problem is the template 
overloading problem, as the compiler will need to instantiate the template with 
each combination of enum inferences just to figure out what the type of the 
template is.)


More information about the Digitalmars-d mailing list