lfe_comp(3)
π lfe_comp(3) β the LFE compiler, bestie edition
okay so this is the man page for lfe_comp, aka the Lisp Flavoured Erlang (LFE) compiler module, and honestly? it's kind of the main character of the whole LFE toolchain. π
β¨ NAME β¨
lfe_comp β Lisp Flavoured Erlang (LFE) compiler. that's it, that's the vibe. π
πΈ SYNOPSIS πΈ
bestie. listen. this module gives you an interface to the standard LFE compiler, and the compiler is lowkey iconic because it can handle files which contain multiple modules. multiple!! it can either generate new files that hold the object code, or return binaries which you can load directly. slay. β¨
π¦ EXPORTS π¦
file(FileName) -> CompRet
literally just the same as file(FileName, [report]). no cap.
file(FileName, Options) -> CompRet
where:
CompRet = ModRet | BinRet | ErrRet
ModRet = {ok,[ModOk]} | {ok,[ModOk],Warnings}
ModOk = {ok,ModuleName} | {ok,ModuleName,Warnings}
BinRet = {ok,[ModBin]} | {ok,[ModBin],Warnings}
ModBin = {ok,ModuleName,Binary} | {ok,ModuleName,Binary,Warnings}
ErrRet = error | {error,[ModErr],Errors,Warnings}
ModErr = {error,Errors,Warnings}
this compiles an LFE file, either writing the generated modules out to files or returning them as binaries. and like, the generated modules are already ready to be loaded into Erlang. iconic behaviour. π
the currently recognised options are (every single one, i'm not skipping anything):
binaryβ return the binary of the module and do not save it in a file. it's giving "no physical form, just vibes". π«Άno_docs,no-docsβ do not parse docstrings, and don't write the"LDoc"chunk in the binary of the module.to_expand,to-expandβ print a listing of the macro expanded LFE code in the file.expand. no object file is produced. mainly useful for debugging and interest.to_lint,to-lintβ print a listing of the macro expanded and linted LFE code in the files.lint. no object files are produced. mainly useful for debugging and interest.to_erlang,to-erlangβ print a listing of the Erlang AST in the file.erl. no object files are produced. mainly useful for debugging and interest.to_core0,to-core0,to_core,to-coreβ print a listing of the Core Erlang code before/after being optimised in the files.core. no object files are produced. mainly useful for debugging and interest.to_kernel,to-kernelβ print a listing of the Kernel Erlang code in the files.kernel. no object files are produced. mainly useful for debugging and interest.to_asm,to-asmβ print a listing of the Beam code in the files.S. no object files are produced. mainly useful for debugging and interest.{outdir,Dir},[outdir,Dir]β save the generated files in directoryDirinstead of the current directory. moving out, but make it compiler output. π{i,Dir},[i,Dir]β addDirto the list of directories to be searched when including a file.reportβ print the errors and warnings as they occur. very "keep me posted" of it.returnβ return an extra return field containingWarningson success, or the errors and warnings in{error,Errors,Warnings}when there are errors.debug_print,debug-printβ causes the compiler to print a lot of debug information. a LOT. it's giving yapper. πwarnings_as_errors,warnings-as-errorsβ causes warnings to be treated as errors. harsh but fair.no_export_macros,no-export-macrosβ do not export macros from modules.
heads up bestie: if the binary option is given, then options that produce listing files will cause the internal formats for that compiler pass to be returned. so like, different delivery, same tea. π΅
both Warnings and Errors have the following format:
[{FileName,[ErrorInfo]}]
ErrorInfo is described below (keep scrolling, it's right there π). when generating Errors and Warnings, the line number is the line of the start of the form in which the error occurred. the file name has been included here to be compatible with the Erlang compiler. and as yet β fr fr β there is no extra information about included files. π
forms(Forms) -> CompRet
same as forms(Forms, [report]). obviously. π
forms(Forms, Options) -> CompRet
where:
Forms = [sexpr()]
CompRet = BinRet | ErrRet
BinRet = {ok,[ModBin]} | {ok,[ModBin],Warnings}
ModBin = {ok,ModuleName,Binary} | {ok,ModuleName,Binary,Warnings}
ErrRet = error | {error,[ModErr],Errors,Warnings}
ModErr = {error,Errors,Warnings}
this compiles the Forms as an LFE module and returns a binary. it takes the same options as lfe_comp:file/1/2. and when generating Errors and Warnings, the βline numberβ is the index of the form in which the error occurred. different numbering, same drama. β¨
format_error(Error) -> Chars
uses an ErrorDescriptor and returns a deep list of characters which describes the error. this function is usually called implicitly when an ErrorInfo structure is processed. see below. π«‘
π₯ ERROR INFORMATION π₯
the ErrorInfo mentioned above is the standard ErrorInfo structure that gets returned from all IO modules. it looks like this:
{ErrorLine,Module,ErrorDescriptor}
and you get a string describing the error with the following call:
Module:format_error(ErrorDescriptor)
that's the whole thing. short, sweet, iconic. π
π SEE ALSO π
go read those too, iykyk. π
β AUTHORS β
Robert Virding.
okay that's the whole page, bestie π this one's from the 2008-2016 era, source/version lfe_comp(3) β like a little vintage handbag but make it compiler docs. mwah π
π¦ 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