JuliaTeachingCTU / Scientific-Programming-in-Julia

Repository for B0M36SPJ
https://juliateachingctu.github.io/Scientific-Programming-in-Julia/dev/
MIT License
78 stars 15 forks source link

Another nice example for hygiene #33

Open pevnak opened 2 years ago

pevnak commented 2 years ago
module A
f() = println("hello")
macro foo()
      :(f())
end
end
Main.A

julia> f() = println("goodbye")
f (generic function with 1 method)

julia> A.@foo
hello

and compare this to

module A
f() = println("hello")
macro foo()
      :(esc(f())))
end
end