lfe_macro(3)

πŸ“¦ version 2.2.0, in alpine 3.24, nixos 26.05, nixpkgs unstable

πŸ’– 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