Last active
March 25, 2017 16:29
-
-
Save jc00ke/caef080fb8a40f14b092f24461914d27 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 Foo do | |
defmacro foo_macro(i) do | |
quote do | |
unquote(i) | |
end | |
end | |
def bar(foo_macro(1) = i), do: IO.puts(i) | |
def bar(foo_macro(2) = i) do | |
IO.puts "This better be 2: #{i}" | |
end | |
end | |
Foo.bar(1) | |
# => 1 | |
Foo.bar(2) | |
# => This better be 2: 2 | |
Foo.bar(3) | |
#** (FunctionClauseError) no function clause matching in Foo.bar/1 | |
# foo.exs:8: Foo.bar(3) | |
# (elixir) lib/code.ex:370: Code.require_file/2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@wobh yeah, that was my position, but others at the meeting didn't think it works work that way. This is a small POC to show them it actually worked.