Why does this not work?
julia> m = Module()
Main.anonymous
julia> @eval m include("foo.jl")
ERROR: UndefVarError: `include` not defined in `Main.anonymous`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] top-level scope
@ none:1
[2] eval(m::Module, e::Any)
@ Core ./boot.jl:430
[3] top-level scope
@ REPL[35]:1
m
is not a baremodule and the include()
docstring says that every module that isn't a baremodule gets its own include()
definition.
Don't know why it doesn't work, but according to the docstring, the solution might be using Base.include
, as in
julia> Base.include(m, "foo.jl")
Does that work for you?
Yeah that's what I'm using as a workaround for now.
Last updated: Dec 28 2024 at 04:38 UTC