Still in a very early state, https:://<a href="http://github.com/hyperthunk/annotations">github.com/hyperthunk/annotations</a> now supports generating additional functions as well as instrumenting existing (i.e., annotated) ones with before/after/around. As an example of how to use this, I've written up a sample application that can be used to generate tedious/boilerplate wrapper functions: <a href="https://github.com/hyperthunk/delegate">https://github.com/hyperthunk/delegate</a>.<div>
<br></div><div>A typical use of delegate is to remove the need to hand code the named 'wrapper' functions for this AST builder that produces a generic representation of applying a 'binary operator':</div><div>
<br></div><div><div>-delegate([</div><div> %% pass the generated/target function name </div><div> %% in front of the input arguments </div><div> {args, ['$T', '$I']}, </div><div> %% let the generated function(s) have a different arity</div>
<div> {arity, 2},</div><div> %% generate functions with/for each of these names...</div><div> {delegate, [</div><div> "eq", "gt",</div><div> "gteq", "lt",</div>
<div> "lteq", "like", </div><div> "contains", "starts_with",</div><div> "ends_with", "matches", "path_exists"</div><div> ]}]).</div>
<div>binop(Op, Axis, {{_,_,_}, _}=Literal) -></div><div> binop(Op, Axis, {literal, Literal});</div><div>binop(Op, Axis, Literal) when is_integer(Literal) orelse</div><div> is_float(Literal) orelse</div>
<div> is_list(Literal) orelse</div><div> is_record(Literal, semver) -></div><div> binop(Op, Axis, {literal, Literal});</div><div>binop(Op, Axis, {literal, _}=Literal) -></div>
<div> {Axis, {operator, Op}, Literal}.</div></div><div><br></div><div><br></div><div>None of this would be possible without the awesome parse_trans library, so a big thank you is due to Ulf for that really killer tool! Roadmap for 0.0.3 is mainly runtime module/code changes via parse_trans_mod.</div>
<div><br></div><div><br></div>