Introduction
Roughly:
Use case 1: Runtime eval
julia> module WorldAgeProblemRaisedHere!
do_this!(one_ary_fn_ast::Expr, arg) = begin
eval(one_ary_fn_ast)(arg)
end
res = do_this!(:(x -> x + 1), 2)
@info res
end
ERROR: MethodError: no method matching (::getfield(Main.WorldAgeProblemRaisedHere!, Symbol("##1#2")))(::Int64)
The applicable method may be too new: running in world age 26095, while current world is 26096.
julia> module WorldAgeProblemSolvedHere!
using GeneralizedGenerated
do_this!(one_ary_fn_ast::Expr, arg) = begin
runtime_eval(one_ary_fn_ast)(arg)
end
res = do_this!(:(x -> x + 1), 2)
@info res
end
[ Info: 3
Main.WorldAgeProblemSolvedHere!
Use case 2: generalized generated functions
using GeneralizedGenerated
@gg function f(x)
quote
a -> x + a
end
end
f(1)(2) # => 3
Known cases not working and workarounds
Special thanks to
Future and what I expect
-
support multiple dispatch in runtime made functions, like in this way.
-
support generators for generated functions(see item 4 in the first list of this section):
Due to an implementation limitation, this also means that they currently cannot define a closure or generator.
-
do this exhaustively/make this bugfree: GitHub - JuliaStaging/JuliaVariables.jl: The implementation of NameResolution.jl for Julia language.
-
more people get involved in and make this work more robust