Last active
October 21, 2015 23:17
-
-
Save mzemel/992c6ad0331ef4744e88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Scope do | |
defmacro update_local(val) do | |
local_var = "first" | |
result = quote do | |
local_var = unquote(val) | |
IO.puts "In macro usage: #{local_var}" | |
end | |
IO.puts "In macro definition: #{local_var}" | |
result | |
end | |
end | |
defmodule Test do | |
require Scope | |
local_var = "third" | |
Scope.update_local("second") | |
IO.puts "On return: #{local_var}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment