You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when using @generated in conjunction with @nloops, i get an UndefVarError(symbol("@nloops")) error when the built executable is run on the command line. the code runs fine when (a) either macro is used alone, or (b) the source is evaluated in the REPL. any ideas? see code below.
importall Base.Cartesian
# this does NOT work
@generated function foo{T,N}(A::Array{T,N})
println(N)
quote
@nloops $N i A begin
println(@nref($N,A,i))
end
end
end
#= but this DOES work
@generated function foo(A)
println(A)
quote
println(A)
end
end
# and so DOES this
function foo(A)
@nloops 3 i A begin
println(@nref(3,A,i))
end
end
=#
function main()
println("hello world!")
foo(rand(3,3,3))
end
this blog seems relevant, but i don't entirely understand it.
The text was updated successfully, but these errors were encountered:
This is due to scoping of the module, when compiling the script. If you shall have the same experience in the REPL then you can only use the import statment. See https://github.com/dhoegh/BuildExecutable.jl/blob/master/test/test.jl where JSON is imported. Even if changing the import to using the functions from the JSON package should still be qualified with JSON.
when using
@generated
in conjunction with@nloops
, i get anUndefVarError(symbol("@nloops"))
error when the built executable is run on the command line. the code runs fine when (a) either macro is used alone, or (b) the source is evaluated in the REPL. any ideas? see code below.this blog seems relevant, but i don't entirely understand it.
The text was updated successfully, but these errors were encountered: