Authors: : Ulf Wiger (ulf@wiger.net).
Compile-time expansion utility
This module serves as an example of parse_trans-based transforms,
but might also be a useful utility in its own right.
The transform searches for calls to the pseudo-function
ct_expand:term(Expr), and then replaces the call site with the
result of evaluating Expr at compile-time.
For example, the line
ct_expand:term(lists:sort([3,5,2,1,4]))
would be expanded at compile-time to [1,2,3,4,5].
ct_expand has now been extended to also evaluate calls to local functions. See examples/ct_expand_test.erl for some examples.
A debugging facility exists: passing the option {ct_expand_trace, Flags} as an option, or adding a compiler attribute -ct_expand_trace(Flags) will enable a form of call trace.
Flags can be [] (no trace) or [F], where F is c (call trace),
r (return trace), or x (exception trace)'.
form() = any()
forms() = [form()]
options() = [{atom(), any()}]
| extract_fun/3 | |
| lfun_rewrite/2 | |
| parse_transform/2 |
extract_fun(Name, Arity, Forms) -> any()
lfun_rewrite(Exprs, Forms) -> any()
Generated by EDoc, Feb 18 2025, 16:31:01.