Last active
May 25, 2016 19:07
-
-
Save chvanikoff/5aef7c0a52eb1b98b2cbe05b6ac95bb3 to your computer and use it in GitHub Desktop.
This file contains 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 Tst do | |
defmacro mymacro(fname) do | |
quote do | |
def run(unquote(fname)) do | |
IO.inspect(unquote(fname)) | |
end | |
end | |
end | |
mymacro("one") | |
end |
This file contains 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 Tst.Macro do | |
defmacro mymacro(fname) do | |
quote do | |
def run(unquote(fname)) do | |
IO.inspect(unquote(fname)) | |
end | |
end | |
end | |
end | |
defmodule Tst do | |
import Tst.Macro | |
mymacro("one") | |
end |
This file contains 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 Tst do | |
defmacro mymacro(arg) do | |
quote do | |
"==" <> unquote(arg) <> "==" | |
end | |
end | |
def run(arg) do | |
IO.inspect mymacro(arg) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment