Skip to content

Instantly share code, notes, and snippets.

@henrik
Created November 18, 2015 21:45
Show Gist options
  • Save henrik/b037602c0697e37e6696 to your computer and use it in GitHub Desktop.
Save henrik/b037602c0697e37e6696 to your computer and use it in GitHub Desktop.
defmodule Twelixir do
defmacro __using__(_) do
quote do
import Kernel, except: [@: 1]
import Twelixir
end
end
defmacro @({name, _, [message]}) do
var = Macro.var(name, __MODULE__)
quote do
send var!(unquote(var)), unquote(message)
end
end
end
defmodule Example do
use Twelixir
def run do
pid = spawn fn ->
receive do
{:hello, thing} -> IO.puts "Hi, #{thing}!"
end
end
@pid {:hello, "Twitter"}
end
end
Example.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment