Skip to content

Instantly share code, notes, and snippets.

@josevalim
Created March 12, 2014 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save josevalim/9511340 to your computer and use it in GitHub Desktop.
Save josevalim/9511340 to your computer and use it in GitHub Desktop.
defmodule MyReceive do
defmacro my_receive(do: clauses) do
extra = quote do
other -> IO.puts "got #{inspect other}"
end
quote do
receive do: unquote(clauses ++ extra)
end
end
end
defmodule Sample do
import MyReceive
send self, :world
my_receive do
:hello -> IO.puts "hello"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment