📝Common Lisp: special operators

Special operators are forms that are neither functions, nor macros. They provide lower-level building blocks for the rest of the functions and macros.

In Common Lisp, there are 25 special operators.

  • Controlling evaluation:

    • quote, if, progn
  • Manipulating the Lexical Environment

    • let, let*
    • setq
    • flet, labels: similar to let but define functions. flet names can only be references in the body, but labels names can be references immediately within labels definitions.
    • macrolet, symbol-macrolet
    • function: gets function object (reader macro: #')
  • Local Flow of Control

    • block + return-from: return from a block/function immediately

      • block + return-from work correctly across function boundaries unwinding the stack. (The block label is lexically scoped, not dynamically.)

        • important note: the labels have dynamic extent—you cannot return-from a block that is no longer on a stack.
    • tagbody + go: low-level goto construct

      • tagbody + go also work across function boundaries unwinding the stack as needed
  • Unwinding the Stack

    • catch and throw: are dynamic counterparts of block and return-from

    • unwind-protect: ensure some code is always executed if stack is unwinding

      (unwind-protect protected-form
  • Multiple Values

  • eval-when

    ;; Basic form:
    (eval-when (situation*)

    Possible situations: :compile-toplevel, :load-toplevel, and :execute

  • other

    • locally
    • the
    • load-time-value
    • progv


Want to receive my 🖋 posts as I publish them?