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

Walter Bright newshound2 at digitalmars.com
Sat Nov 19 04:14:18 UTC 2022


On 11/18/2022 7:05 PM, Timon Gehr wrote:
> On 19.11.22 03:54, Walter Bright wrote:
>> With the syntax $e to look up an enum member, the compiler will need to search 
>> *every* enum that is in scope. Since one of D's strengths is whole program 
>> compilation, this can be slow. To speed that up, it will likely require that 
>> the compiler maintain a hash table of all the enum fields.
>>
>> I.e. a parallel symbol table will have to be maintained alongside the regular 
>> symbol table. 
> 
> Not true. E.g. see my example with delegates.

I was thinking of the general case of $a being able to find member `a` among all 
the enums in scope.

You're referring, of course, to the "contextual" part of the DIP, where the 
lookup works only in a subset of cases. The contextual lookup can result in some 
odd cases like:

---- module A ----
     private enum E { e; };
     public void dra(E);
------------------
     import A;

     dra($e);
------------------

Is that a good thing? I'm not sure. This is also not addressed in the DIP.




More information about the Digitalmars-d mailing list