Skip to content

Commit

Permalink
asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Vorreuter committed Oct 28, 2009
1 parent bac0a91 commit 7c31ac8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
Binary file modified hacking_erlang.key
Binary file not shown.
5 changes: 4 additions & 1 deletion src/example1.erl
@@ -1,4 +1,7 @@
-module(example1). -module(example1).
-compile({parse_transform, print_forms}).
-export([foo/0]). -export([foo/0]).


foo() -> "Hello Stockholm!". foo() -> "Hello Stockholm!".


41 changes: 21 additions & 20 deletions src/example2.erl
@@ -1,21 +1,22 @@
-module(example2). -module(example2).
-compile({parse_transform, expand_records}). % -compile({parse_transform, expand_records}).
-export([encode_record/1]). % -export([record_to_proplist/1]).

%
-record(pizza, {size, toppings, price}). % -record(pizza, {size, toppings, price}).

%
encode_record(Rec) -> % record_to_proplist(Rec) when is_tuple(Rec) ->
[RecName|Fields] = tuple_to_list(Rec), % [RecName|Fields] = tuple_to_list(Rec),
FieldNames = expanded_record_fields(RecName), % FieldNames = expanded_record_fields(RecName),
lists:zip(FieldNames, Fields). % lists:zip(FieldNames, Fields).

%

%
encode_record(Rec) -> % record_to_proplist(Rec) when is_tuple(Rec) ->
case Rec of % case Rec of
Pizza when is_record(Pizza, pizza) -> % Pizza when is_record(Pizza, pizza) ->
[{size, Pizza#pizza.size}, % [{size, Pizza#pizza.size},
{toppings, Pizza#pizza.toppings}, % {toppings, Pizza#pizza.toppings},
{price, Pizza#pizza.price}]; % {price, Pizza#pizza.price}];
_ -> % _ ->
exit(wtf_do_i_do_with_this) % exit(wtf_do_i_do_with_this)
end. % end.
%
8 changes: 8 additions & 0 deletions src/print_forms.erl
@@ -0,0 +1,8 @@
-module(print_forms).
-export([parse_transform/2]).

parse_transform(Forms, _Options) ->
io:format("forms: ~p~n", [Forms]),
Forms.


0 comments on commit 7c31ac8

Please sign in to comment.