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