This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
emp2 /
README.md
Erlang Macro Processor (v2)
Put on GitHub by Andreas Stenius.
This is the emp2 written by Philip Robinson. See his blog for full details: http://chlorophil.blogspot.com/2007/04/erlang-macro-processor-v2-part-v.html
Example usage
The macro definition (in it's own module):
-module(example_macro).
-export([lookup_binary/1]).
lookup_binary(Size) ->
[[$,,FirstVal]|NumberString] = lists:map(
fun(Offset) -> io_lib:format(",~B", [Offset * 2]) end,
lists:seq(0, Size - 1)),
"<<" ++ [FirstVal] ++ NumberString ++ ">>".
Then you may use it from other modules:
-module(example).
-export([lookup/1]).
-compile({parse_transform, emp2}).
-macro_modules([example_macro]).
lookup(Offset) ->
<<_:Offset/binary,Value:8/integer,_/binary>> =
example_macro:lookup_binary(4),
Value.
Example output:
1> [example:lookup(N) || N <- lists:seq(0, 3)].
[0,2,4,6]
2>
Erlang Macro Processor (v1)
Is also supported (see http://chlorophil.blogspot.com/2007/04/erlang-macro-processor-v1-part-i.html).








