1.0.23.36: typecheck :ALLOCATION :CLASS slot initforms in safe code
[sbcl/tcr.git] / doc / sbcl.1
blob2f86938e8c0cd5d6584d01776634862dcbca6257
1 .\" -*- Mode: Text -*-
2 .\"
3 .\" man page introduction to SBCL
4 .\"
5 .\" SBCL, including this man page, is derived from CMU Common Lisp, of
6 .\" which it was said (ca. 1991)
7 .\"   **********************************************************************
8 .\"   This code was written as part of the CMU Common Lisp project at
9 .\"   Carnegie Mellon University, and has been placed in the public domain.
10 .\"   If you want to use this code or any part of CMU Common Lisp, please
11 .\"   contact Scott Fahlman or slisp-group@cs.cmu.edu.
12 .\"   **********************************************************************
13 .\" Most of SBCL, including this man page, is in the public domain. See
14 .\" COPYING in the distribution for more information.
15 .\"
16 .TH SBCL 1 "$Date$"
17 .AT 3
18 .SH NAME
19 SBCL -- Steel Bank Common Lisp
21 .SH DESCRIPTION
23 SBCL is an implementation of ANSI Common Lisp, featuring a
24 high-performance native compiler, native threads on several platforms,
25 a socket interface, a source-level debugger, a statistical profiler,
26 and much more.
28 It is free software, mostly in the public domain, but with some
29 subsystems under BSD-style licenses which allow modification and reuse
30 as long as credit is given. It is provided "as is", with no warranty
31 of any kind.
33 For more information about license issues, see the COPYING file in
34 the distribution. For more information about history, see the 
35 CREDITS file in the distribution.
37 .SH RUNNING SBCL
39 To run SBCL, type "sbcl". After startup messages a prompt
40 ("\f(CR*\fR") appears. Enter a Lisp expression, and SBCL will read and
41 execute it, print any values returned, give you another prompt, and
42 wait for your next input.
44 \f(C
45   $ sbcl
46   ...[startup messages elided]...
47   * (+ 1 2 3)
49   6
50   * (quit)
51 \fR
53 Most people like to run SBCL as a subprocess under Emacs. The Emacs
54 "Slime" mode provides many convenient features, like command line
55 editing, tab completion, and various kinds of coupling between Common
56 Lisp source files and the interactive SBCL subprocess.
58 For information on creating "standalone executables" using SBCL, see
59 \f(CRSB\-EXT:SAVE\-LISP\-AND\-DIE\fR in the User Manual.
61 .SH COMMAND LINE SYNTAX
63 For ordinary interactive use, no command line arguments should be
64 necessary.
66 In order to understand the SBCL command line syntax, it is helpful to
67 understand that the system is composed of two parts: a runtime
68 environment, and the Common Lisp system it supports. Some command line
69 arguments are processed during the initialization of the runtime, and
70 some during the initialization of the Lisp system -- any remaining
71 command line arguments are passed on to user code.
73 The overall command line syntax is:
74 .TP 3
75 .B sbcl [runtime options] \-\-end\-runtime\-options [toplevel options] \-\-end\-toplevel\-options [user options]
76 .PP
78 Both \-\-end\-runtime\-options and \-\-end\-toplevel\-options are
79 optional, and may be omitted. They are intended for use in situations
80 where any command line options are under user control (eg. in batch
81 files): by using them you can prevent options intended for your
82 program being accidentally processed by SBCL.
84 Supported runtime options are
85 .TP 3
86 .B \-\-core <corefilename>
87 Use the specified Lisp core file instead of the default. (See the FILES
88 section for the standard core, or the system documentation for
89 \f(CRSB\-EXT:SAVE\-LISP\-AND\-DIE\fR for information about how to create a 
90 custom core.) Note that if the Lisp core file is a user-created core
91 file, it may run a nonstandard toplevel which does not recognize the
92 standard toplevel options.
93 .TP 3
94 .B \-\-dynamic-space-size <megabytes>
95 Size of the dynamic space reserved on startup in megabytes. Default value
96 is platform dependent.
97 .TP 3
98 .B \-\-control-stack-size <megabytes>
99 Size of control stack reserved for each thread in megabytes. Default value
100 is 2.
101 .TP 3
102 .B \-\-noinform
103 Suppress the printing of any banner or other informational message at
104 startup. (This makes it easier to write Lisp programs which work
105 cleanly in Unix pipelines. See also the "\-\-noprint" and
106 "\-\-disable\-debugger" options.)
107 .TP 3
108 .B \-\-script <filename>
109 As a runtime option equivalent to \-\-noinform
110 \-\-end\-toplevel\-options \-\-script <filename>. See the description
111 of \-\-script as a toplevel option below.
112 .TP 3
113 .B \-\-help
114 Print some basic information about SBCL, then exit.
115 .TP 3
116 .B \-\-version
117 Print SBCL's version information, then exit.
120 In the future, runtime options may be added to control behavior such
121 as lazy allocation of memory.
123 Runtime options, including any \-\-end\-runtime\-options option,
124 are stripped out of the command line before the
125 Lisp toplevel logic gets a chance to see it.
127 The toplevel options supported by the standard SBCL core are
128 .TP 3
129 .B \-\-sysinit <filename>
130 Load filename instead of the default system-wide initialization file.
131 (See the FILES section.)
132 .TP 3
133 .B \-\-no\-sysinit
134 Do not load a system-wide initialization file. If this option is
135 given, the \-\-sysinit option is ignored.
136 .TP 3
137 .B \-\-userinit <filename>
138 Load filename instead of the default user initialization file. (See
139 the FILES section.)
140 .TP 3
141 .B \-\-no\-userinit
142 Do not load a user initialization file. If this option is
143 given, the \-\-userinit option is ignored.
144 .TP 3
145 .B \-\-eval <command>
146 After executing any initialization file, but before starting the
147 read-eval-print loop on standard input, read and evaluate the command
148 given. More than one \-\-eval option can be used, and all will be read
149 and executed, in the order they appear on the command line.
150 .TP 3
151 .B \-\-load <filename>
152 This is equivalent to \-\-eval \(aq(load "<filename>")\(aq. The special
153 syntax is intended to reduce quoting headaches when invoking SBCL
154 from shell scripts.
155 .TP 3
156 .B \-\-noprint
157 When ordinarily the toplevel "read-eval-print loop" would be executed,
158 execute a "read-eval loop" instead, \fIi.e.\fR don't print a prompt and
159 don't echo results. Combined with the \-\-noinform runtime option, this
160 makes it easier to write Lisp "scripts" which work cleanly in Unix
161 pipelines.
162 .TP 3
163 .B \-\-disable\-debugger
164 By default when SBCL encounters an error, it enters the builtin
165 debugger, allowing interactive diagnosis and possible intercession.
166 This option disables the debugger, causing errors to print a backtrace
167 and exit with status 1 instead -- which is a mode of operation better suited
168 for batch processing. See the User Manual on \f(CRSB\-EXT:DISABLE\-DEBUGGER\fR for details.
169 .B \-\-script <filename>
170 Implies \-\-no-sysinit \-\-no-userinit \-\-disable-debugger
171 \-\-end\-toplevel\-options.
173 Causes the system to load the specified file and exit immediately
174 afterwards, instead of entering the readl-eval-print loop. If the file
175 begins with a shebang line, it is ignored.
178 Regardless of the order in which toplevel options appear on the command
179 line, the order of actions is:
181 .nr step 1 1
182 .IP \n[step]. 3
183 Debugger is disabled, if requested.
184 .IP \n+[step].
185 Any system initialization file is loaded, unless prohibited.
186 .IP \n+[step].
187 Any user initialization file is loaded, unless prohibited.
188 .IP \n+[step].
189 \-\-eval and \-\-load options are processed in the order given.
192 Finally, either the read-eval-print loop is entered or the file
193 specified with \-\-script option is loaded.
195 When running in the read-eval-print loop the system exits on end of
196 file. Similarly, the system exits immediately after processing the
197 file specified with \-\-script.
199 Note that when running SBCL with the \-\-core option, using a core
200 file created by a user call to the
201 \f(CRSB\-EXT:SAVE\-LISP\-AND\-DIE\fR, the toplevel options may be
202 under the control of user code passed as arguments to
203 \f(CRSB\-EXT:SAVE\-LISP\-AND\-DIE\fR. For this purpose, the
204 \-\-end\-toplevel\-options option itself can be considered a toplevel
205 option, \fIi.e.\fR the user core, at its option, may not support it.
207 In the standard SBCL startup sequence (\fIi.e.\fR with no user core
208 involved) toplevel options and any \-\-end\-toplevel\-options option are
209 stripped out of the command line argument list before user code gets a
210 chance to see it.
212 .SH OVERVIEW
214 SBCL is derived from the CMU CL. (The name is intended to acknowledge
215 the connection: steel and banking are the industries where Carnegie
216 and Mellon made the big bucks.)
218 SBCL compiles by default: even functions entered in the
219 read-eval-print loop are compiled to native code, unless the evaluator
220 has been explicitly turned on. (Even today, some 30 years after the
221 MacLisp compiler, people will tell you that Lisp is an interpreted
222 language. Ignore them.)
224 SBCL aims for but has not completely achieved compliance with the ANSI
225 standard for Common Lisp. More information about this is available in
226 the BUGS section below.
228 SBCL also includes various non-ANSI extensions, described more fully
229 in the User Manual.  Some of these are in the base system and others
230 are "contrib" modules loaded on request using \f(CRREQUIRE\fR.  For
231 example, to load the \f(CRSB\-BSD\-SOCKETS\fR module that provides
232 TCP/IP connectivity,
233 \f(CR
234    * (require \(aqasdf)
235    * (require \(aqsb\-bsd\-sockets)
238 For more information, see the User Manual.
241 .SH THE COMPILER
243 SBCL inherits from CMU CL the "Python" native code compiler. (Though
244 we often avoid that name in order to avoid confusion with the
245 scripting language also called Python.) This compiler is very clever
246 about understanding the type system of Common Lisp and using it to
247 optimize code, and about producing notes to let the user know when the
248 compiler doesn't have enough type information to produce efficient
249 code. It also tries (almost always successfully) to follow the unusual
250 but very useful principle that "declarations are assertions", \fIi.e.\fR
251 type declarations should be checked at runtime unless the user
252 explicitly tells the system that speed is more important than safety.
254 The compiled code uses garbage collection to automatically manage
255 memory. The garbage collector implementation varies considerably from
256 CPU to CPU. In particular, on some CPUs the GC is nearly exact, while
257 on others it's more conservative, and on some CPUs the GC is
258 generational, while on others simpler stop and copy strategies are
259 used.
261 For more information about the compiler, see the user manual.
263 .SH SYSTEM REQUIREMENTS
265 SBCL currently runs on X86 (Linux, FreeBSD, OpenBSD, and NetBSD),
266 X86-64 (Linux), Alpha (Linux, Tru64), PPC (Linux, Darwin/MacOS X),
267 SPARC (Linux and Solaris 2.x), and MIPS (Linux). For information on
268 other ongoing and possible ports, see the sbcl\-devel mailing list,
269 and/or the web site.
271 SBCL requires on the order of 16Mb RAM to run on X86 systems, though
272 all but the smallest programs would be happier with 32Mb or more.
274 .SH KNOWN BUGS
276 This section attempts to list the most serious and long-standing bugs.
277 For more detailed and current information on bugs, see the BUGS file
278 in the distribution.
280 It is possible to get in deep trouble by exhausting heap memory.  The
281 SBCL system overcommits memory at startup, so, on typical Unix-alikes
282 like Linux and FreeBSD, this means that if the SBCL system turns out
283 to use more virtual memory than the system has available for it, other
284 processes tend to be killed randomly (!).
286 The compiler's handling of function return values unnecessarily
287 violates the "declarations are assertions" principle that it otherwise
288 adheres to. Using \f(CRPROCLAIM\fR or \f(CRDECLAIM\fR to specify the
289 return type of a function causes the compiler to believe you without
290 checking. Thus compiling a file containing
291 \f(CR
292   (DECLAIM (FTYPE (FUNCTION (T) NULL) SOMETIMES))
293   (DEFUN SOMETIMES (X) (ODDP X))
294   (DEFUN FOO (X) (IF (SOMETIMES X) \(aqTHIS\-TIME \(aqNOT\-THIS\-TIME))\fR
296 then running \f(CR(FOO 1)\fR gives \f(CRNOT\-THIS\-TIME\fR, because
297 the compiler relied on the truth of the \f(CRDECLAIM\fR without checking it.
299 Some things are implemented very inefficiently.
300 .TP 3
302 Multidimensional arrays are inefficient, especially
303 multidimensional arrays of floating point numbers.
304 .TP 3
306 SBCL, like most (maybe all?) implementations of Common Lisp on stock
307 hardware, has trouble passing floating point numbers around
308 efficiently, because a floating point number, plus a few extra bits to
309 identify its type, is larger than a machine word. (Thus, they get
310 "boxed" in heap-allocated storage, causing GC overhead.) Within a
311 single compilation unit, or when doing built-in operations like
312 \f(CRSQRT\fR and \f(CRAREF\fR, or some special operations like
313 structure slot accesses, this is avoidable: see the user manual for
314 some efficiency hints. But for general function calls across the
315 boundaries of compilation units, passing the result of a floating
316 point calculation as a function argument (or returning a floating
317 point result as a function value) is a fundamentally slow operation.
320 .SH REPORTING BUGS
322 To report a bug, please send mail to the mailing lists sbcl-help or
323 sbcl-devel. You can find the complete mailing list addresses on the
324 web pages at <\f(CRhttp://sbcl.sourceforge.net/\fR>; note that as a
325 spam reduction measure you must subscribe to the lists before you can
326 post. (You may also find fancy SourceForge bug-tracking machinery
327 there, but don't be fooled. As of 2002-07-25 anyway, we don't actively
328 monitor that machinery, and it exists only because we haven't been
329 able to figure out how to turn it off.)
331 As with any software bug report, it's most helpful if you can provide
332 enough information to reproduce the symptoms reliably, and if you say
333 clearly what the symptoms are.  For example, "There seems to be
334 something wrong with TAN of very small negative arguments. When I
335 execute \f(CR(TAN LEAST\-NEGATIVE\-SINGLE\-FLOAT)\fR interactively on
336 sbcl-1.2.3 on my Linux 4.5 X86 box, I get an \f(CRUNBOUND\-VARIABLE\fR
337 error."
339 .SH DIFFERENCES FROM CMU CL
341 SBCL can be built from scratch using a plain vanilla ANSI Common Lisp
342 system and a C compiler, and all of its properties are specified by
343 the version of the source code that it was created from. This clean
344 bootstrappability was the immediate motivation for forking off of the
345 CMU CL development tree. A variety of implementation differences are
346 motivated by this design goal.
348 Maintenance work in SBCL since the fork has diverged somewhat from the
349 maintenance work in CMU CL. Many but not all bug fixes and
350 improvements have been shared between the two projects, and sometimes
351 the two projects disagree about what would be an improvement.
353 Most extensions supported by CMU CL have been unbundled from SBCL,
354 including Motif support, the Hemlock editor, search paths, the WIRE
355 protocol, various user-level macros and functions (\fIe.g.\fR
356 \f(CRLETF\fR, \f(CRITERATE\fR, \f(CRMEMQ\fR, \f(CRREQUIRED\-ARGUMENT\fR),
357 and many others.
359 (Why doesn't SBCL support more extensions natively? Why drop all those
360 nice extensions from CMU CL when the code already exists? This is a
361 frequently asked question on the mailing list. There are two principal
362 reasons. First, it's a design philosophy issue: arguably SBCL has done
363 its job by supplying a stable FFI, and the right design decision is to
364 move functionality derived from that, like socket support, into
365 separate libraries. Some of these are distributed with SBCL as
366 "contrib" modules, others are distributed as separate software
367 packages by separate maintainers. Second, it's a practical decision -
368 focusing on a smaller number of things will, we hope, let us do a
369 better job on them.)
371 .SH SUPPORT
373 Various information about SBCL is available at
374 <\f(CRhttp://www.sbcl.org/\fR>. The mailing lists there are the recommended
375 place to look for support.
377 .SH AUTHORS
379 Dozens of people have made substantial contributions to SBCL and its
380 subsystems, and to the CMU CL system on which it was based, over the
381 years. See the CREDITS file in the distribution for more information.
383 .SH ENVIRONMENT
385 .TP 10n
386 .BR SBCL_HOME
387 This variable controls where files like "sbclrc", "sbcl.core", and the
388 add-on "contrib" systems are searched for.  If it is not set, then
389 sbcl sets it from a compile-time default location which is usually
390 /usr/local/lib/sbcl/ but may have been changed \fIe.g.\fR by a third-party
391 packager.
393 .SH FILES
396 .I sbcl
397 executable program containing some low-level runtime support and
398 a loader, used to read sbcl.core
400 .I sbcl.core
401 dumped memory image containing most of SBCL, to be loaded by
402 the `sbcl' executable.  Looked for in $\f(CRSBCL_HOME\fR,
403 unless overridden by the \f(CR\-\-core\fR option.
405 .I sbclrc
406 optional system-wide startup script, looked for in $\f(CRSBCL_HOME\fR/sbclrc
407 then /etc/sbclrc, unless overridden by the \f(CR\-\-sysinit\fR command line
408 option.
410 .I .sbclrc
411 optional per-user customizable startup script (in user's home
412 directory, or as specified by  \f(CR\-\-userinit\fR)
414 .SH SEE ALSO
416 Full SBCL documentation is maintained as a Texinfo manual. If is has
417 been installed, the command
419 .B info sbcl
421 should give you access to the complete manual. Depending on your
422 installation it may also be available in HTML and PDF formats in eg.
424 .B /usr/local/share/doc/sbcl/
426 See the SBCL homepage 
428 .B <\f(CRhttp://www.sbcl.org/\fR>
430 for more information, including directions on how to subscribe to the
431 sbcl\-devel and sbcl\-help mailing-lists.