Normally, generated functions can only use methods defined earlier:
julia> f(x) = 1
julia> @generated g(x...) = f(x...)
julia> f(x, y) = 2
julia> g(1)
1
julia> g(1, 1)
ERROR: MethodError: no method matching f(::Type{Int64}, ::Type{Int64})
The applicable method may be too new: running in world age 33465, while current world is 33466.
How can I make Julia recompile g
whenever f
changes (new f
methods get defined)? That’s definitely possible, Tricks.jl does this stuff, but I couldn’t really understand nor utilize code from that package so that g
works in the above example.
Can you please advice on how to achieve that? I guess some compilation backedges need to be inserted, but couldn’t adapt Tricks code for such a case myself.