0.6.11.42:
[sbcl.git] / doc / sbcl.1
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 .\"
14 .TH SBCL 1 "$Date$"
15 .AT 3
16 .SH NAME
17 SBCL -- "Steel Bank Common Lisp"
18
19 .SH DESCRIPTION
20
21 SBCL is a free Common Lisp programming environment. It is derived from
22 the free CMU CL programming environment. (The name is intended to
23 acknowledge the connection: steel and banking are the industries where
24 Carnegie and Mellon made the big bucks.)
25
26 .SH COMMAND LINE SYNTAX
27
28 Command line syntax can be considered an advanced topic; for ordinary
29 interactive use, no command line arguments should be necessary.
30
31 In order to understand the command line argument syntax for SBCL, it
32 is helpful to understand that the SBCL system is implemented as two
33 components, a low-level runtime environment written in C and a
34 higher-level system written in Common Lisp itself. Some command line
35 arguments are processed during the initialization of the low-level
36 runtime environment, some command line arguments are processed during
37 the initialization of the Common Lisp system, and any remaining
38 command line arguments are passed on to user code.
39
40 The full, unambiguous syntax for invoking SBCL at the command line is
41 .TP 3
42 .B sbcl [runtime options] --end-runtime-options [toplevel options] --end-toplevel-options [user options]
43 .PP
44
45 For convenience, the --end-runtime-options and --end-toplevel-options
46 elements can be omitted. Omitting these elements can be convenient
47 when you are running the program interactively, and you can see that
48 no ambiguities are possible with the option values you are using.
49 Omitting these elements is probably a bad idea for any batch file
50 where any of the options are under user control, since it makes it
51 impossible for SBCL to detect erroneous command line input, so that
52 erroneous command line arguments will be passed on to the user program
53 even if they was intended for the runtime system or the Lisp system.
54
55 Supported runtime options are
56 .TP 3
57 .B --core <corefilename>
58 Run the specified Lisp core file instead of the default. (See the FILES
59 section.) Note that if the Lisp core file is a user-created core file, it may
60 run a nonstandard toplevel which does not recognize the standard toplevel
61 options.
62 .TP 3
63 .B --noinform
64 Suppress the printing of any banner or other informational message at
65 startup. (This makes it easier to write Lisp programs which work in
66 Unix pipelines. See also the "--noinform" option.)
67 .PP
68
69 In the future, runtime options may be added to control behavior such
70 as lazy allocation of memory.
71
72 Runtime options, including any --end-runtime-options option,
73 are stripped out of the command line before the
74 Lisp toplevel logic gets a chance to see it.
75
76 Supported toplevel options for the standard SBCL core are
77 .TP 3
78 .B --sysinit <filename>
79 Load filename instead of the default system-wide initialization file.
80 (See the FILES section.) There is no special option to cause no
81 system-wide initialization file to be read, but on a Unix system
82 "--sysinit /dev/null" can be used to achieve the same effect.
83 .TP 3
84 .B --userinit <filename>
85 Load filename instead of the default user initialization file. (See
86 the FILES section.) There is no special option to cause no user
87 initialization file to be read, but on a Unix system "--userinit
88 /dev/null" can be used to achieve the same effect.
89 .TP 3
90 .B --eval <command>
91 After executing any initialization file, but before starting the
92 read-eval-print loop on standard input, evaluate the command given.
93 More than one --eval option can be used, and all will be executed, in
94 the order they appear on the command line.
95 .TP 3
96 .B --noprint
97 When ordinarily the toplevel "read-eval-print loop" would be executed,
98 execute a "read-eval loop" instead, i.e. don't print a prompt and
99 don't echo results. Combined with the --noinform runtime option, this
100 makes it easier to write Lisp "scripts" which work in Unix pipelines.
101 .TP 3
102 .B --noprogrammer
103 By default, a Common Lisp system tries to ask the programmer for help
104 when it gets in trouble (by printing a debug prompt on *DEBUG-IO*).
105 However, this is not useful behavior for a system running with no
106 programmer available, and this option tries to set up more appropriate
107 behavior for that situation. Thus we set *DEBUG-IO* to send its
108 output to *ERROR-OUTPUT*, and to raise an error if any input is
109 requested from it; and we set *DEBUGGER-HOOK* to output a backtrace,
110 then exit the process with a failure code.
111 .PP
112
113 Regardless of the order in which --sysinit, --userinit, and --eval
114 options appear on the command line, the sysinit file, if it exists, is
115 loaded first; then the userinit file, if it exists, is loaded; then
116 any --eval commands are executed in sequence; then the read-eval-print
117 loop is started on standard input. At any step, error conditions or
118 commands such as SB-EXT:QUIT can cause execution to be terminated
119 before proceeding to subsequent steps.
120
121 Note that when running SBCL with the --core option, using a core file
122 created by a user call to the SB-EXT:SAVE-LISP-AND-DIE, the toplevel
123 options may be under the control of user code passed as arguments to
124 SB-EXT:SAVE-LISP-AND-DIE. For this purpose, the --end-toplevel-options
125 option itself can be considered a toplevel option, i.e. the user core,
126 at its option, may not support it.
127
128 In the standard SBCL startup sequence (i.e. with no user core
129 involved) toplevel options and any --end-toplevel-options option are
130 stripped out of the command line argument list before user code gets a
131 chance to see it.
132
133 .SH OVERVIEW
134
135 SBCL aims for but has not reached ANSI compliance.
136
137 SBCL compiles Lisp to native code, or optionally to more-compact but
138 much slower byte code.
139
140 SBCL's garbage collector is generational and conservative.
141
142 SBCL includes a source level debugger, as well as the ANSI TRACE
143 facility and a rudimentary profiler.
144
145 .SH DIFFERENCES FROM CMU CL
146
147 SBCL can be built from scratch using a plain vanilla ANSI Common Lisp
148 system and a C compiler, and all of its properties are specified by
149 the version of the source code that it was created from. (This clean
150 bootstrappability was the immediate motivation for forking off of the
151 CMU CL development tree.) A variety of internal implementation
152 differences are motivated by this.
153
154 Maintenance work in SBCL since the fork has diverged in various
155 details from the maintenance work in CMU CL. E.g. as of 2001-04-12,
156 SBCL was more ANSI-compliant than CMU CL in various details such as
157 support for PRINT-OBJECT and DESCRIBE-OBJECT, and SBCL's compiler was
158 substantially better than CMU CL's at optimizing operations on
159 non-simple vectors.
160
161 Most extensions supported by CMU CL are not supported in SBCL,
162 including Motif support, the Hemlock editor, search paths, the
163 low-level Unix interface, the WIRE protocol, multithreading support,
164 various user-level macros and functions (e.g. LETF, ITERATE, MEMQ,
165 REQUIRED-ARGUMENT), and many others.
166
167 SBCL has retained some extensions from parent CMU CL. Many of the
168 retained extensions are in these categories:
169 .TP 3
170 \--
171 things which might be in the new ANSI spec, e.g. weak pointers,
172 finalization, foreign function interface to C, and Gray streams
173 .TP 3
174 \--
175 things which are universally available in Unix scripting languages,
176 e.g. RUN-PROGRAM and POSIX argv and getenv
177 .TP 3
178 \--
179 hooks into the low level workings of the system which can be useful
180 for debugging, e.g. a list of functions to be run whenever GC occurs,
181 or parameters to modify compiler diagnostic output
182 .TP 3
183 \--
184 unportable performance hacks, e.g. TRULY-THE, FREEZE-TYPE, and PURIFY
185 .PP
186
187 There are also a few retained extensions which don't fall into
188 any particular category, e.g.
189 .TP 3
190 \--
191 the ability to save running Lisp images as executable files
192 .PP
193
194 Some of the retained extensions have new names and/or different
195 options than their CMU CL counterparts. For example, the SBCL function
196 which saves a Lisp image to disk and kills it is called
197 SAVE-LISP-AND-DIE instead of SAVE-LISP, and it supports fewer keyword
198 options than CMU CL's SAVE-LISP.
199
200 (Why doesn't SBCL support more extensions? Why the hell did I (WHN)
201 drop all those nice extensions from CMU CL when the code already
202 exists? This is a frequently asked question on the mailing list. The
203 answer is that they're hard to maintain, and I have enough on my hands
204 already. Also, in the case of some big and unquestionably useful
205 extensions, like sockets and Motif, I think that SBCL has done its job
206 by supplying the FFI, and that people who need, and understand, and
207 are motivated to maintain the functionality should supply it as a
208 separate library, which I'd be happy to distribute or link to on the
209 SBCL home page. Finally, in the case of multithreading, I do think it
210 belongs in the new ANSI spec, and it'd be a good feature to have, but
211 I didn't think the CMU CL implementation was sufficiently mature, and
212 it's such a complicated and far-reaching extension that I thought that
213 trying to fix it would interfere with the more urgent task of getting
214 basic ANSI support up to speed.)
215
216 .SH THE COMPILER
217
218 SBCL inherits from CMU CL the "Python" native code compiler. This
219 compiler is very clever about understanding the type system of Common
220 Lisp and using it to produce efficient code, and about producing notes
221 to let the user know when the compiler doesn't have enough type
222 information to produce efficient code. It also tries (almost always
223 successfully) to follow the unusual but very useful principle that
224 type declarations should be checked at runtime unless the user
225 explicitly tells the system that speed is more important than safety.
226
227 The CMU CL version of this compiler reportedly produces pretty good
228 code for modern machines which have lots of registers, but its code
229 for the X86 is marred by a lot of extra loads and stores to
230 stack-based temporary variables. Because of this, and because of the
231 extra levels of indirection in Common Lisp relative to C, we find a
232 typical performance decrease by a factor of perhaps 2 to 5 for small
233 programs coded in SBCL instead of GCC.
234
235 For more information about the compiler, see the user manual.
236
237 .SH DOCUMENTATION
238
239 Currently, the documentation for the system is
240 .TP 3
241 \--
242 the user manual
243 .TP 3
244 \--
245 this man page
246 .TP 3
247 \--
248 doc strings and online help built into the SBCL executable
249 .PP
250
251 .SH SYSTEM REQUIREMENTS
252
253 Unlike its distinguished ancestor CMU CL, SBCL is currently only
254 supported on X86. Linux, FreeBSD, and OpenBSD ports are currently
255 available. It would probably be straightforward to port the CMU CL
256 support for SPARC or Alpha, or to port to NetBSD. Some work on a
257 port to the Alpha has been reported on the mailing lists; check
258 the archives (available from the home page at
259 <http://sbcl.sourceforge.net/>) for information.
260
261 As of version 0.6.11, SBCL requires on the order of 16Mb to run. In
262 some future version, this number could shrink significantly, since
263 large parts of the system are far from execution bottlenecks and could
264 reasonably be stored in compact byte compiled form. (CMU CL does this
265 routinely; the only reason SBCL doesn't currently do this is a
266 combination of bootstrapping technicalities and inertia.)
267
268 .SH ENVIRONMENT
269
270 .TP 10n
271 .BR SBCL_HOME
272 If this variable is set, it overrides the default directories for
273 files like "sbclrc" and "sbcl.core", so that instead of being searched
274 for in e.g. /etc/, /usr/local/etc/, /usr/lib/, and /usr/local/lib/, they
275 are searched for only in the directory named by SBCL_HOME. This is
276 intended to support users who wish to use their own version of SBCL
277 instead of the version which is currently installed as the system
278 default.
279 .PP
280
281 .SH FILES
282
283 /usr/lib/sbcl.core and /usr/local/lib/sbcl.core are the standard
284 locations for the standard SBCL core, unless overridden by the SBCL_HOME
285 variable.
286
287 /etc/sbclrc and /usr/local/etc/sbclrc are the standard locations for
288 system-wide SBCL initialization files, unless overridden by the
289 SBCL_HOME variable or the --sysinit command line option.
290
291
292 $HOME/.sbclrc is the standard location for a user's SBCL
293 initialization file, unless overridden by the --userinit
294 command line option.
295
296 .SH BUGS
297
298 To report a bug, please send mail to sbcl-help@lists.sourceforge.net
299 or sbcl-devel@lists.sourceforge.net. As with any software bug report,
300 it's most helpful if you remember to describe the environment where
301 the problem occurs (machine type, O/S name and version, etc.) and if
302 you can provide enough information to reproduce the problem,
303 preferably in compact form.
304
305 This section attempts to list the most serious and long-standing bugs
306 or surprising performance hits. For more detailed and current
307 information on bugs, see the BUGS file in the distribution.
308
309 It is possible to get in deep trouble by exhausting
310 memory. To plagiarize a sadly apt description of a language not
311 renowned for the production of bulletproof software, "[The current
312 SBCL implementation of] Common Lisp makes it harder for you to shoot
313 yourself in the foot, but when you do, the entire universe explodes."
314 .TP 3
315 \--
316 The system doesn't deal well with stack overflow.
317 .TP 3
318 \--
319 The SBCL system overcommits memory at startup. On typical Unix-alikes
320 like Linux and *BSD, this means that if the SBCL system turns out to
321 use more virtual memory than the system has available for it, other
322 processes to be killed randomly (!)
323 .PP
324
325 The compiler is overaggressive about static typing, assuming that a
326 function's return type never changes. Thus compiling and loading a
327 file containing
328 (DEFUN FOO (X) NIL)
329 (DEFUN BAR (X) (IF (FOO X) 1 2))
330 (DEFUN FOO (X) (PLUSP X))
331 then running (FOO 1) gives 2 (because the compiler "knew"
332 that FOO's return type is NULL).
333
334 The compiler's handling of function return values unnecessarily
335 violates the "declarations are assertions" principle that it otherwise
336 adheres to. Using PROCLAIM or DECLAIM to specify the return type of a
337 function causes the compiler to believe you without checking. Thus
338 compiling a file containing
339 (DECLAIM (FTYPE (FUNCTION (T) NULL) SOMETIMES))
340 (DEFUN SOMETIMES (X) (ODDP X))
341 (DEFUN FOO (X) (IF (SOMETIMES X) 'THIS-TIME 'NOT-THIS-TIME))
342 then running (FOO 1) gives NOT-THIS-TIME, because the
343 never compiled code to check the declaration.
344
345 The implementation of multidimensional arrays, especially
346 multidimensional arrays of floating point numbers, is very
347 inefficient.
348
349 SYMBOL-FUNCTION is much slower than you might expect, being
350 implemented not as a slot access but as a search through the
351 compiler/kernel "globaldb" database.
352
353 CLOS (based on the PCL reference implementation) is somewhat
354 inefficient.
355
356 There are many nagging pre-ANSIisms, e.g.
357 .TP 3
358 \--
359 CLOS (based on the PCL reference implementation) is incompletely
360 integrated into the system, so that e.g. SB-PCL::FIND-CLASS is a
361 different function than CL::FIND-CLASS. (This is less of a problem in
362 practice than the speed, but it's still distasteful.)
363 .TP 3
364 --
365 The ANSI-recommended idiom for creating a function which is only
366 sometimes expanded inline,
367 (DECLAIM (INLINE F))
368 (DEFUN F ...)
369 (DECLAIM (NOTINLINE F)),
370 doesn't do what you'd expect. (Instead, you have to declare the
371 function as SB-EXT:MAYBE-INLINE to get the desired effect.)
372 .TP 3
373 \--
374 The DYNAMIC-EXTENT declaration is not implemented, and is simply
375 ignored. (This is allowed by the ANSI spec, but can have a large
376 efficiency cost in some kinds of code, e.g. code which uses a lot
377 of upward closures or &REST lists.)
378 .TP 3
379 --
380 Compiling DEFSTRUCT in strange places (e.g. inside a DEFUN) doesn't
381 do anything like what it should.
382 .TP 3
383 \--
384 The symbol * is the name of a type similar to T. (It's used as part of
385 the implementation of compound types like (ARRAY * 1) and (CONS * *).
386 In a strict ANSI implementation, * would not be the name of a type,
387 but instead just a symbol which is recognized and handled specially by
388 certain type expanders.)
389 .PP
390
391 .SH SUPPORT
392
393 Various information about SBCL is available at
394 <http://sbcl.sourceforge.net/>. The mailing lists there are the
395 recommended place to look for support.
396
397 .SH DISTRIBUTION
398
399 SBCL is a free implementation of Common Lisp derived from CMU CL. Both
400 sources and executables are freely available; this software is "as
401 is", and has no warranty of any kind. CMU and the authors assume no
402 responsibility for the consequences of any use of this software. See
403 the CREDITS file in the distribution for more information about
404 history, contributors and permissions.
405