Overloading based on attributes - is it a good idea?

Jonathan Marler johnnymarler at gmail.com
Wed May 29 02:50:24 UTC 2019


On Wednesday, 29 May 2019 at 01:14:04 UTC, Walter Bright wrote:
> 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.

You do realize that all template code literally compiles to 
nothing right?

A template isn't code, it's just a "template" that can be 
instantiated.  If all you have is templates then there's nothing 
to instantiate them.



More information about the Digitalmars-d mailing list