All pages
Docs · The languageMarkdown
Special forms
Forms the evaluator treats specially, before function application. Their
names are reserved in binding positions: binding if, quote, dotimes
or any other name below is E-EVAL-005. Everything else, including every
prelude macro and builtin, can be shadowed.
A malformed special form is E-EVAL-005 with the expected shape.
Core
| form | shape | page |
|---|---|---|
quote | (quote x), 'x | |
quasiquote | `(a ,b ,@c) | macros |
if | (if test then [else]); the chosen branch keeps multiple values | control |
progn | (progn form...) | |
let | (let ((name value)...) body...), initializers in the enclosing scope | functions |
let* | (let* ((name value)...) body...), each binding in a new scope | functions |
setq | (setq name value [name value]...), rebinds existing variables | functions |
lambda | (lambda lambda-list body...) | functions |
flet | (flet ((name lambda-list body...)...) body...) | functions |
labels | the same, mutually recursive | functions |
macrolet | (macrolet ((name lambda-list body...)...) body...) | macros |
dotimes | (dotimes (i count [result]) body...) | control |
dolist | (dolist (item list [result]) body...) | control |
multiple-value-bind | (multiple-value-bind (names...) expr body...) | control |
multiple-value-list | (multiple-value-list expr) | control |
multiple-value-call | (multiple-value-call f expr...) | control |
multiple-value-prog1 | (multiple-value-prog1 expr body...) | control |
destructuring-bind | (destructuring-bind pattern list body...) | functions |
macroexpand-1, macroexpand | (macroexpand form [env]) | macros |
intern | (intern string [env]) | macros |
Definitions
| form | shape | page |
|---|---|---|
defun | (defun name lambda-list body...) | functions |
defmacro | (defmacro name macro-lambda-list body...) | macros |
defvar | (defvar name value), once per module | |
require | (require "module" name...), module top level only | require |
Experiment
| form | shape | page |
|---|---|---|
defmodel | (defmodel name lambda-list body... fn) | models |
defparam | (defparam name initializer &key tags numerics), inside a model | models |
with-numerics | (with-numerics (:sensitivity :high) body...) | numerics |
defoptimizer | (defoptimizer name (param grad ctx &key ...) body...) | optimizers |
defstate | (defstate name zero-initializer), inside an optimizer | optimizers |
defknobs | (defknobs (name default ["doc"])...) | knobs |
defvariant | (defvariant name (knob value)...) | knobs |
defsweep | (defsweep name [:variant v] (knob [values])...) | knobs |
defeval | (defeval name :loader l [:every n] [:batches k]) | evaluation |
defrun | (defrun :steps n ...) | defrun |
Definitions register when their form executes, so a macro can generate any
of them; see generated declarations.
The configuration constructors (loader, stage, files, manifest,
field, select, group, named) are ordinary builtins; see
builtins.