My package Convertible.jl currently uses generated functions to enable multi-step type conversions at runtime. The problem is that I achieved this by calling methods within the generated function body, i.e. I am observing mutable global state which is considered harmful.
I am now in the process of rewriting the package and want to shift the generation of the missing intermediate convert methods to compile-time by using a macro. The question is now whether this actually solves the problem? Can macros safely observe method tables?
I don’t know enough about he internals or your code to say how exactly it would fail, but since macros should just perform syntax transformations, you are probably better off just rewriting the code a different way.
Perhaps if you gave a bit of context, or an MWE that would illustrate the problem you are trying to solve, you could get an alternative solution.
What makes it complicated is that I want the user to be able to add new types to the graph at runtime. Maybe the whole thing is premature optimization. I must confess I have not checked whether looking up the intermediate conversion dynamically would actually perform much worse.