Quick question : generated functions and later defined functions

Hi,

Here,https://docs.julialang.org/en/v1/manual/metaprogramming/#Generated-functions-1,
it says " generated function cannot call any method that was not defined prior to the definition of the generated function itself."

Is there a way to go beyond this? like including the later defined methods in the dispatch without using them in the generated expression.

Is this related to world age problem? And if so why Base.invokelast doesn’t work.

Thanks

This package: https://github.com/NHDaly/StagedFunctions.jl is trying to get around that restriction.

1 Like

How is it trying to that? Do you know, GitHub page doesn’t have much info.
Thanks

You write an abstract interpreter that itself is pure, but can return an total description of both the result and the methods needed to derive it.

so basically, what if I apply Core._apply_pure , it should solve my problem? Huh?

That can never be right as that function isn’t valid to use (outside of the compiler itself), but I can’t speak to the quality of any particular implementation. I’m just saying what you would need to implement.

1 Like