Last active
January 11, 2018 09:01
-
-
Save elixirplayground/59127abfd2d937ebf9b6eafb936009ff to your computer and use it in GitHub Desktop.
elixirplayground.com code share
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 M do | |
defmacro __using__(_args) do | |
quote do | |
@count 0 | |
import unquote(__MODULE__), only: :macros | |
end | |
end | |
defmacro p do | |
quote do | |
@count @count + 1 | |
def p_unquote(@count), do: @count | |
end | |
end | |
end | |
defmodule A do | |
use M | |
p() | |
p() | |
p() | |
end | |
IO.puts A.p_1() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment