# \[ANN\] GeneralizedGenerated.jl: less restricted @generated functions and runtime eval mechanism

**URL:** <https://discourse.julialang.org/t/ann-generalizedgenerated-jl-less-restricted-generated-functions-and-runtime-eval-mechanism/28725>\
**Category:** Package Announcements\
**Tags:** package, announcement, metaprogramming\
**Created:** [September 13, 2019, 4:27pm UTC](https://discourse.julialang.org/t/ann-generalizedgenerated-jl-less-restricted-generated-functions-and-runtime-eval-mechanism/28725 "2019-09-13T16:27:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thautwarm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thautwarm/32/37760_2.png) [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Post date:** [September 13, 2019, 4:27pm UTC](https://discourse.julialang.org/t/ann-generalizedgenerated-jl-less-restricted-generated-functions-and-runtime-eval-mechanism/28725/1 "2019-09-13T16:27:11Z")

</div>

# Introduction

Roughly:

## Use case 1: Runtime eval

```julia-auto
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

```julia-auto
using GeneralizedGenerated

@gg function f(x)
    quote
        a -> x + a
    end
end

f(1)(2) # => 3

```

## Known cases not working and workarounds

[https://github.com/thautwarm/GeneralizedGenerated.jl/issues/20](https://github.com/thautwarm/GeneralizedGenerated.jl/issues/20)

## Special thanks to

@cscherrer

## Future and what I expect

- support multiple dispatch in runtime made functions, like [in this way](https://github.com/thautwarm/GeneralizedGenerated.jl/issues/6#issuecomment-528193160).

- support generators for generated functions(see item 4 in the first list of [this section](https://docs.julialang.org/en/v1/manual/metaprogramming/#Generated-functions-1)):

- do this exhaustively/make this bugfree: [GitHub - JuliaStaging/JuliaVariables.jl: The implementation of NameResolution.jl for Julia language.](https://github.com/thautwarm/JuliaVariables.jl)

- more people get involved in and make this work more robust
