Skip to content
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

load behaviour is different with/without begin...end #44104

Closed
Roger-luo opened this issue Feb 10, 2022 · 1 comment
Closed

load behaviour is different with/without begin...end #44104

Roger-luo opened this issue Feb 10, 2022 · 1 comment

Comments

@Roger-luo
Copy link
Contributor

I come originally from https://discourse.julialang.org/t/from-from-fromfile-does-not-work-inside-begin-en-for-local-module-workflow/76100/2

MWE

julia> begin
       using LinearAlgebra
       LinearAlgebra.@commutative
       end
ERROR: LoadError: UndefVarError: LinearAlgebra not defined
in expression starting at REPL[1]:3

I think Pluto users put every commands inside begin ... end so this should be considered equivalent to have the following directly in REPL

using LinearAlgebra
LinearAlgebra.@commutative

I'm not sure why the module followed with a macro is somehow evaluated before the module is loaded? I think most people would expect this to work.

@simeonschaub
Copy link
Member

Those two aren't equivalent. Macro expansion will always happen on the whole top-level expression before any code is evaluated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants