Created
June 20, 2015 02:45
-
-
Save hamiltop/fec14c8ed6f0639df156 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 Test do | |
defmacro foo_macro(bar, block) do | |
IO.inspect bar | |
IO.inspect block | |
end | |
def foo(bar, block) do | |
IO.inspect bar | |
IO.inspect block | |
end | |
defmacro puts(string) do | |
IO.puts string | |
end | |
end | |
defmodule Run do | |
def run do | |
require Test | |
Test.puts "Macro with nums" | |
Test.foo_macro(1,2) | |
Test.puts "Macro with expr" | |
_ = Test.foo_macro(1 + 1, 2 + 2) | |
Test.puts "Macro with expr and do" | |
Test.foo_macro(1 + 1) do | |
2 + 2 | |
end | |
Test.puts "macro with expr and explicit do keyword list" | |
Test.foo_macro(1 + 1, [do: 2 + 2]) | |
IO.puts "function with nums" | |
Test.foo(1,2) | |
IO.puts "function with expr" | |
Test.foo(1 + 1, 2 + 2) | |
IO.puts "function with expr do" | |
Test.foo(1 + 1) do | |
2 + 2 | |
end | |
IO.puts "function with expr and explicit do keyword list" | |
Test.foo(1 + 1, [do: 2 + 2]) | |
end | |
end | |
Run.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output
elixir do_block.ex
: