JuliaLang / Distributed.jl

Create and control multiple Julia processes remotely for distributed computing. Ships as a Julia stdlib.
https://docs.julialang.org/en/v1/stdlib/Distributed/
MIT License
20 stars 8 forks source link

Don't rely on implicit binding creation by setglobal #102

Closed Keno closed 1 month ago

Keno commented 1 month ago

As discussed in [1], the implicit creation of bindings through the setglobal! intrinsic was accidentally added in 1.9 unintentionally and will be removed (ideally) or at the very least deprecated in 1.11.

The recommended replacement syntax is Core.eval(mod, Expr(:global, sym)) to introduce the binding and invokelatest(setglobal!, mod, sym, val) to set it. The invokelatest is not presently required, but may be required for https://github.com/JuliaLang/julia/pull/54654, so it's included in the recommendation.

[1] https://github.com/JuliaLang/julia/issues/54607

Keno commented 1 month ago

Also needs a 1.11 backport.

vchuravy commented 1 month ago

For my own reference pre-1.9 this was a direct ccall https://github.com/JuliaLang/julia/pull/44753

Keno commented 1 month ago

It feels a little premature to say that invokelatest will definitely work in exactly this way

That's why I said may be required not will be required ;). Also you actually have to hit the github approve button or I can't merge this without using evil superuser priviliges.