-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
_get_body extracts the type encoding of the body of GG functions.
julia> fun = mk_function(Main, :(function (x) x + 1 end))
function = (x;) -> begin
begin
(Main).:+(x, 1)
end
end
julia> from_type(GeneralizedGenerated._get_body(fun))
quote
begin
#= REPL[27]:1 =#
#= REPL[27]:1 =#
(Main).:+(x, 1)
end
endThis is very useful to control scopes.
For instance, if we want to specify bind values to local variables in the generated body, we can firstly create a dummy function and specify arguments which will be bound to our values.
@gg function f(M::Module, a, b)
c = 1
fun = mk_function(M, :(function (a, b, c)
...
end))
body = from_type(_get_body(fun))
quote
let c = $c
$body
end
end
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels