Closed slepher closed 5 years ago
while import attributes is imported to macro extra argument Attributes is added to macro function while called. it includes all attributes of module mentioned in proplist key attrs
special attrs:
module: module use_macro
line: line where macro used
-module(a). -behaviour(gen_server). -use_macro({macro_a, macro/2, [{attrs, [module, line, behaviour]}]}). hello() -> macro_a:macro(world).
-module(macro_a). -export([macro/2]). macro(Ast, #{module => Module, line => Line, behaviour => Behaviours} = Attributes) -> io:format("module is ~p, behaviour is ~p", [Module, Behaviours]), Ast.
done
while import attributes is imported to macro extra argument Attributes is added to macro function while called. it includes all attributes of module mentioned in proplist key attrs
special attrs:
module: module use_macro
line: line where macro used