-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically generating a module fails on master (sometimes on 0.2) #5276
Comments
I wouldn't generate the module by trying to poke at it externally with Generating top-level expressions with
|
Thanks! But eval( Expr(:toplevel, :(module MyMod; const myconst = var ...; end))) seems to sometimes put the constants in the parent module instead (on master). I'll try to isolate a test case later. (I understand why you recommend against it, #1974 will be better solution if it gets implemented) |
sorry, that was on 0.2 (mixing up my julia executables), on master it works all fine. Thanks! |
To create a module in the root namespace use module A
function create_module(modname::Symbol)
Expr(:toplevel, :(module ($modname) end))
end
e = A.create_module(:B)
println(e)
eval(Main, e)
end
B
#$(Expr(:toplevel, :($(Expr(:module, true, :B, :(begin
# eval(x) = top(Core).eval(B,x)
# eval(m,x) = top(Core).eval(m,x)
# end)))), :B))
#
# B |
I'm experimenting a bit with auto-generating bindings to Gtk3/Clutter/etc using GObject-introspection in a fork of Gtk.jl (https://github.com/bfredl/Gtk.jl )
My current approach depends on dynamically generating modules and I'm using
However, create_module(:MyMod) fails on Julia master (syntax error in eval), and crashes non-deterministically on 0.2 stable. Actually my test cases running inside Gtk.jl mostly never crashes, but the above code usually segfaults when run on its own in a fresh interactive 0.2 session. (under arch linux 64bit)
is there a better way to dynamically generate a module (and populate it with constants, etc)? Or maybe I should just wait for #1974 ?
The text was updated successfully, but these errors were encountered: