Overloading based on attributes - is it a good idea?

Jonathan Marler johnnymarler at gmail.com
Tue May 28 22:12:30 UTC 2019


On Tuesday, 28 May 2019 at 21:41:28 UTC, Walter Bright wrote:
> On 5/28/2019 2:12 PM, Jonathan Marler wrote:
>> turtles all the way down.
>
> Again, it is not that simple. Call graphs have cycles in them, 
> they are not acyclic. Furthermore, since you suggested 
> different code be instantiated based on inferred attributes, 
> you have a FAR FAR more complex problem to resolve, since the 
> graph connections change at every decision point.

I read your response again and I think there's another piece you 
might be missing.

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.  Of course, this is just the theory, in practice it's 
just propagated as an implicit template parameter, a feature 
which is probably worth looking into and discussing on its own.



More information about the Digitalmars-d mailing list