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

Timon Gehr timon.gehr at gmx.ch
Tue Nov 22 01:19:32 UTC 2022


On 22.11.22 01:41, Walter Bright wrote:
> On 11/20/2022 2:03 AM, Timon Gehr wrote:
>> To some extent I think this is the case, but function literals already 
>> defer the semantic pass in some way, so it seems feasible.
> 
> True, and templates also make a copy of the AST before instantiating it. 
> But:
> 
> 1. template compilation is not known for speed or low memory consumption
> 
> 2. every function argument would have to be copied first, as it wouldn't 
> know about $ processing in advance (or have to make a pass over it first 
> to detect it)
> ...

I guess the two-pass thing is how function literals work, so you'd do that?

> 3. if there were, say, 5 occurrences of $a, each of that which could be 
> 2 different instances to try, what's that, 32 copies
> 
> I'm not too thrilled about this.

The DIP does not propose trying all combinations. You'd get number of 
function overloads copies for each occurrence of $a. It's not 
exponential and without overloading (I think this is the majority of 
cases in typical user code) it is one copy.


More information about the Digitalmars-d mailing list