Extensions

SBCL is derived from CMU CL, which implements many extensions to the ANSI standard. SBCL doesn't support as many extensions as CMU CL, but it still has quite a few.

Things Which Might Be in the Next ANSI Standard

SBCL provides extensive support for calling external C code, described in its own chapter.

SBCL provides additional garbage collection functionality not specified by ANSI. Weak pointers allow references to objects to be maintained without keeping them from being GCed. And "finalization" hooks are available to cause code to be executed when an object is GCed.

SBCL supports Gray streams, user-overloadable CLOS classes whose instances can be used as Lisp streams (e.g. passed as the first argument to format).

Support for Unix

The UNIX command line can be read from the variable sb-ext:*posix-argv*. The UNIX environment can be queried with the sb-ext:posix-getenv function.

The SBCL system can be terminated with sb-ext:quit, optionally returning a specified numeric value to the calling Unix process. The normal Unix idiom of terminating on end of file on input is also supported.

Tools to Help Developers

SBCL provides a profiler and other extensions to the ANSI trace facility. See the online function documentation for trace for more information.

The debugger supports a number of options. Its documentation is accessed by typing help at the debugger prompt.

Documentation for inspect is accessed by typing help at the inspect prompt.

Interface to Low-Level SBCL Implementation

SBCL has the ability to save its state as a file for later execution. This functionality is important for its bootstrapping process, and is also provided as an extension to the user See the documentation for sb-ext:save-lisp-and-die for more information.

Efficiency Hacks

The sb-ext:purify function causes SBCL first to collect all garbage, then to mark all uncollected objects as permanent, never again attempting to collect them as garbage. (This can cause a large increase in efficiency when using a primitive garbage collector, but is less important with modern generational garbage collectors.)

The sb-ext:truly-the operator does what the cl:the operator does in a more conventional implementation of Common Lisp, declaring the type of its argument without any runtime checks. (Ordinarily in SBCL, any type declaration is treated as an assertion and checked at runtime.)

The sb-ext:freeze-type declaration declares that a type will never change, which can make type testing (typep, etc.) more efficient for structure types.

The sb-ext:constant-function declaration specifies that a function will always return the same value for the same arguments. This is appropriate for functions like sqrt. It is not appropriate for functions like aref, which can change their return values when the underlying data are changed.