Skip to content

Instantly share code, notes, and snippets.

@elixirplayground
Last active January 11, 2018 09:01
Show Gist options
  • Save elixirplayground/59127abfd2d937ebf9b6eafb936009ff to your computer and use it in GitHub Desktop.
Save elixirplayground/59127abfd2d937ebf9b6eafb936009ff to your computer and use it in GitHub Desktop.
elixirplayground.com code share
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