Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Language Features Matrix

This section provides a comprehensive, systematic catalog of all language features in LFE. It serves as a reference for understanding what constructs are available, their syntax, semantics, and usage patterns.

Overview

LFE is a Lisp-2 with:

  • Separate namespaces for functions and variables
  • S-expression syntax (homoiconic)
  • Erlang semantics (immutable data, process-oriented, pattern matching)
  • Full Erlang interoperability (zero-overhead FFI)
  • Powerful macro system (compile-time code transformation)
  • Multiple paradigm support (functional, concurrent, actor-based)

Language Characteristics:

AspectDescription
Type SystemDynamically typed with optional Dialyzer specs
EvaluationEager/strict evaluation (call-by-value)
ScopingLexical scoping with environment-based bindings
ClosuresFull closure support with lambda lifting
Tail CallsTail call optimization (via Erlang/BEAM)
ConcurrencyActor model (Erlang processes)
PersistenceAll data structures immutable
Memory ModelGarbage collected, per-process heaps

Core Forms (23)

quote cons car cdr list tuple binary map
lambda match-lambda
let let* letrec let-function letrec-function let-macro
progn if case receive try catch
call funcall function

Built-in Macros (50+)

defmodule defun defmacro defrecord defstruct
cond when unless do
let* flet fletrec flet*
lc bc qlc
caar cadr cdar cddr ... (c*r family)
list* != === !==

Data Types (13)

atom integer float string binary boolean
list tuple map record struct
function pid port reference

Operators (30+)

Arithmetic: + - * / div rem abs
Comparison: == /= =:= =/= < > =< >=
Boolean: not and or andalso orelse xor
Bitwise: band bor bxor bnot bsl bsr

LFE vs Common Lisp

FeatureLFECommon LispNotes
NamespacesLisp-2Lisp-2Separate function/variable namespaces
EvaluationEagerEagerCall-by-value
TypingDynamicDynamicRuntime type checking
MacrosUnhygienicUnhygienicBoth support quasiquotation
CLOSNoYesLFE uses Erlang behaviors instead
Tail callsYes (BEAM)YesProper TCO
ConcurrencyActors (processes)ThreadsDifferent models
MutabilityImmutableMutableErlang semantics

LFE vs Scheme

FeatureLFESchemeNotes
NamespacesLisp-2Lisp-1LFE has separate namespaces
EvaluationEagerEagerBoth call-by-value
MacrosUnhygienicHygienic (syntax-rules)LFE has unhygienic macros
ContinuationsNoYes (call/cc)BEAM doesn't support
Tail callsYesYesBoth have proper TCO
NumbersErlang typesScheme numbersDifferent numeric tower

LFE vs Clojure

FeatureLFEClojureNotes
PlatformBEAM/ErlangJVMDifferent VMs
NamespacesLisp-2Lisp-1Different conventions
Data structuresErlang typesPersistent collectionsBoth immutable
ConcurrencyActorsAgents/Atoms/STMDifferent models
MacrosTraditionalHygienic-ishClojure has syntax-quote
TypingDynamicDynamicBoth with optional specs
PerformanceBEAM-levelJVM-levelDifferent characteristics