Authors: Serge Aleynikov (saleyn(at)gmail(dot)com).
Conditional expression functions
This module exports a parse transform and implements several condition-checking functions.
When using this as a parse transform, include the{parse_transform,iif}
compiler option. In this case for given expressions A
,B
,C
, and D
the following code transforms will be done:
iif(A, B, C) -> begin V = A, if V -> B; true -> C end end iif(A,B,C,D) -> case A of B -> C; _ -> D end nvl(A,B) -> case A of false -> B; undefined -> B; [] -> B; _ -> A end nvl(A,B,C) -> case A of false -> B; undefined -> B; [] -> B; _ -> C endFor debugging the AST of the resulting transform, use
iif_debug
command-line option:
erlc -Diif_debug=1 ... % Prints AST before the transform erlc -Diif_debug=2 ... % Prints AST after the transform erlc -Diif_debug[=3] ... % Prints AST before/after the transform
parse_transform/2 | Parse transform to be used by providing {parse_transform, iif} option. |
parse_transform(AST, Opts) -> any()
Parse transform to be used by providing {parse_transform, iif}
option.
Opts
are compiler options passed from command line. E.g.:
erlc -Diif_debug=N ... -> Opts = [{d,debug,N}|_] erlc -Diif_debug ... -> Opts = [{d,debug}|_]
Generated by EDoc