Skip to content

Instantly share code, notes, and snippets.

@ricston-git
Last active December 12, 2015 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricston-git/4739226 to your computer and use it in GitHub Desktop.
Save ricston-git/4739226 to your computer and use it in GitHub Desktop.
hello module for "Erlang erl_syntax - usage example" blog post.
-module(hello).
-export([send_hello/1, receive_hello/0]).
send_hello(To) ->
To ! {hello, self()}.
receive_hello() ->
receive
{hello, From} ->
{ok, From};
Msg ->
{unknown_msg, Msg}
end.
[{attribute,1,file,{"../src/hello.erl",1}},
{attribute,1,module,hello},
{attribute,2,export,[{send_hello,1},{receive_hello,0}]},
{function,4,send_hello,1,
[{clause,4,
[{var,4,'To'}],
[],
[{op,5,'!',
{var,5,'To'},
{tuple,5,[{atom,5,hello},{call,5,{atom,5,self},[]}]}}]}]},
{function,7,receive_hello,0,
[{clause,7,[],[],
[{'receive',8,
[{clause,9,
[{tuple,9,[{atom,9,hello},{var,9,'From'}]}],
[],
[{tuple,10,[{atom,10,ok},{var,10,'From'}]}]},
{clause,11,
[{var,11,'Msg'}],
[],
[{tuple,12,[{atom,12,unknown_msg},{var,12,'Msg'}]}]}]}]}]},
{eof,13}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment