|Posted by Timon Gehr|
in reply to Walter Bright
Posted in reply to Walter Bright
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.