I am trying to use the @batch
from Polyester.jl as an alternative to the Base.Threads.@threads but inside my loops I need to define some closures which produced an UndefVarError. A MWE is the following
function func()
@batch for i in 1:5
f(x)=x
end
end
func()
will produce:
ERROR: UndefVarError: `x` not defined
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/Polyester/HaBfT/src/closure.jl:387 [inlined]
[2] func()
@ Main ./REPL[90]:2
[3] top-level scope
@ REPL[91]:1
[4] top-level scope
@ ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1428
Is there a workaround or its a case that I cannot use @batch