Created
November 18, 2015 21:45
-
-
Save henrik/b037602c0697e37e6696 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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