lfe_macro(3)
π NAME π
Okay bestie, meet lfe_macro(3) β the Lisp Flavoured Erlang (LFE) macro expander. That's the name, that's the vibe, periodt. π
β¨ SYNOPSIS β¨
This module provides an interface to the LFE macro expander. The expander is used by the LFE compile and in the shell, but can also be used by applications explicitly wanting to handle a file. Slay, it's flexible. β¨
πΈ DATA TYPES πΈ
sexpr()
An LFE s-expression β a list structure. Literally the building block, no cap. π§
filesexpr() = {Sexpr,Line}
This is the format returned by lfe_io:parse_file/1, and it's used by the compiler to give better error information. Helpful queen behavior. π
env()
This is a macro and evaluation environment as created by lfe_lib:new_env(). Your little macro-evaluation hangout spot. π«Ά
mac_state()
This is the internal state used by the macro expander. Behind-the-scenes main character energy, fr fr. π
π EXPORTS π
expand_expr + expand_expr_1
expand_expr(Sexpr, Env) -> {yes,Exp} | no.
expand_expr_1(Sexpr, Env) -> {yes,Exp} | no.
where
Sexpr = Exp = sexpr()
Env = env()
Test if the top s-expression here is a macro call. If so, expand it and return {yes,Expansion}; if not, return no. expand_expr/2 will expand the top s-expression as much as possible, while expand_expr_1/2 will only try it once. These functions use the macro definitions in the environment and the standard pre-defined macros. Obsessed with the efficiency. β
expand_expr_all
expand_expr_all(Sexpr, Env) -> Sexpr.
where
Sexpr = sexpr()
Env = env()
Expand all macros in Sexpr, either using the definitions in Env or just the default macros. Note that any eventual new macro definitions will be lost. π So don't get attached, bestie.
expand_form_init
expand_form_init(Deep, Keep) -> MacState
where
Deep = boolean()
Keep = boolean()
MacState = mac_state()
Create an internal macro state. Deep determines whether the form is to be expanded internally at depth, and Keep determines whether macro definition forms are to be kept. Cute little setup, honestly. π
expand_fileforms
expand_fileforms([FileForm], Env, Deep, Keep) -> ExpRet
expand_fileforms([FileForm], Env, MacState) -> ExpRet
where
FileForm = filesexpr()
Env = env()
Deep = boolean()
Keep = boolean()
MacState = mac_state()
ExpRet = {yes,[FileSexpr],Env,Warnings} |
{error,Errors,Warnings}
This expands a sequence of file forms. Highkey useful. π₯
expand_form + expand_fileform
expand_form(Form, Line, Env, MacState) -> RetState
expand_fileform(FileForm, Env, MacState) -> RetState
where
Form = sexpr()
FileForm = filesexpr()
Line = integer()
Env = env()
MacState = mac_state()
RetState = {ok,Form,Env,Macstate} |
{error,Errors,Warnings,MacState}
Expand a file form using the environment and macro state. That's the whole vibe. π
π¦ SEE ALSO π¦
π AUTHORS π
Robert Virding. Iconic. π
Later, bestie π
β this page is lfe_macro(3), source/version-and-date 2008-2020, so go forth and expand something iconic. π¦β¨
π¦ where this page comes from
- alpine 3.24: lfe-doc 2.2.0-r2 Β· Apache-2.0
- nixos 26.05: erlang27.3.4.19-lfe 2.2.0
- nixpkgs unstable: erlang27.3.4.19-lfe 2.2.2
- nixpkgs unstable: erlang28.5.0.8-lfe 2.2.2
- nixpkgs unstable: erlang29.1.2-lfe 2.2.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms