Created
July 28, 2014 06:18
-
-
Save CampingScorpion/389a41f2537aafcdfe8c 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
iex(1)> expr = quote do: Unless.macro_unless(true, IO.puts "this should never be printed") | |
{{:., [], [{:__aliases__, [alias: false], [:Unless]}, :macro_unless]}, [], | |
[true, | |
{{:., [], [{:__aliases__, [alias: false], [:IO]}, :puts]}, [], | |
["this should never be printed"]}]} | |
iex(2)> res = Macro.expand_once(expr, __ENV__) | |
{{:., [], [{:__aliases__, [alias: false], [:Unless]}, :macro_unless]}, [], | |
[true, | |
{{:., [], [{:__aliases__, [alias: false], [:IO]}, :puts]}, [], | |
["this should never be printed"]}]} | |
iex(3)> IO.puts Macro.to_string(res) | |
Unless.macro_unless(true, IO.puts("this should never be printed")) | |
:ok | |
iex(4)> res = Macro.expand(expr, __ENV__) | |
{{:., [], [{:__aliases__, [alias: false], [:Unless]}, :macro_unless]}, [], | |
[true, | |
{{:., [], [{:__aliases__, [alias: false], [:IO]}, :puts]}, [], | |
["this should never be printed"]}]} | |
iex(5)> IO.puts Macro.to_string(res) | |
Unless.macro_unless(true, IO.puts("this should never be printed")) | |
:ok |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment