Overloading based on attributes - is it a good idea?

Walter Bright newshound2 at digitalmars.com
Wed May 29 01:14:04 UTC 2019


On 5/28/2019 3:12 PM, Jonathan Marler wrote:
> You are correct that call graphs are not acyclic, however, the inference of 
> attributes only applies to templated-functions, not regular functions.  So we 
> don't need to walk the entire graph to determine whether or not a template is 
> allowed to use the GC, you only need to trace each template to it's nearest 
> non-template function.
Your algorithm will have to work for the worst case, which is all template code. 
This is hardly unreasonable, as Phobos is nearly entirely templates, with 
cyclical expansions. Worse, it's not just attribute inference, you proposed 
different code paths for different attributes, meaning the graph changes, too.

It's a combinatorial explosion.


More information about the Digitalmars-d mailing list