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