Typo and other small fixes in the manuals and the man page
[sbcl.git] / doc / manual / deprecated.texinfo
1 @node Deprecated Interfaces
2 @comment  node-name,  next,  previous,  up
3 @chapter Deprecated Interfaces
4
5 This chapter documents the deprecation process used for SBCL
6 interfaces, and lists legacy interfaces in various stages of
7 deprecation.
8
9 This should not be confused with those things the ANSI Common Lisp
10 standard calls ``deprecated'': the entirety of ANSI CL is supported by
11 SBCL, and none of those interfaces are subject to censure.
12
13 @section Why Deprecate?
14
15 While generally speaking we try to keep SBCL changes as backwards
16 compatible as feasible, there are situations when existing interfaces
17 are deprecated:
18
19 @itemize
20
21 @item @strong{Broken Interfaces}
22
23 Sometimes it turns out that an interface is sufficiently misdesigned
24 that fixing it would be worse than deprecating it and replacing it
25 with another.
26
27 This is typically the case when fixing the interface would change its
28 semantics in ways that could break user code subtly: in such cases we
29 may end up considering the obvious breakage caused by deprecation to
30 be preferable.
31
32 Another example are functions or macros whose current signature makes
33 them hard or impossible to extend in the future: backwards compatible
34 extensions would either make the interface intolerably hairy, or are
35 sometimes outright impossible.
36
37 @item @strong{Internal Interfaces}
38
39 SBCL has several internal interfaces that were never meant to be used
40 in user code -- or at least never meant to be used in user code
41 unwilling to track changes to SBCL internals.
42
43 Ideally we'd like to be free to refactor our own internals as we
44 please, without even going through the hassle of deprecating things.
45 Sometimes, however, it turns out that our internal interfaces have
46 several external users who aren't using them advicedly, but due to
47 misunderstandings regarding their status or stability.
48
49 Consider a deprecated internal interface a reminder for SBCL
50 maintainers not to delete the thing just yet, even though it is seems
51 unused -- because it has external users.
52
53 When internal interfaces are deprecated we try our best to provide
54 supported alternatives.
55
56 @item @strong{Aesthetics & Ease of Maintenance}
57
58 Sometimes an interface isn't broken or internal, but just inconsistent
59 somehow.
60
61 This mostly happens only with historical interfaces inherited from
62 CMUCL which often haven't been officially supported in SBCL before, or
63 with new extensions to SBCL that haven't been around for very long in
64 the first place.
65
66 The alternative would be to keep the suboptimal version around
67 forever, possibly alongside an improved version. Sometimes we may do
68 just that, but because every line of code comes with a maintenance
69 cost, sometimes we opt to deprecate the suboptimal version instead:
70 SBCL doesn't have infinite developer resources.
71
72 We also believe that sometimes cleaning out legacy interfaces helps
73 keep the whole system more comprehensible to users, and makes
74 introspective tools such as @code{apropos} more useful.
75
76 @end itemize
77
78 @section What Happens During Deprecation?
79
80 Deprecation proceeds in three stages, each lasting approximately a
81 year. In some cases it might move slower or faster, but one year per
82 stage is what we aim at in general.
83
84 During each stage warnings (and errors) of increasing severity are
85 signaled, which note that the interface is deprecated, and point users
86 towards any replacements when applicable.
87
88 @enumerate
89
90 @item @strong{Early Deprecation}
91
92 During early deprecation the interface is kept in working condition,
93 but a style-warning will be signalled for uses of it at compile-time.
94
95 The internals may change at this stage: typically because the interface
96 is re-implemented on top of its successor. While we try to keep things
97 as backwards-compatible as feasible (taking maintenance costs into account),
98 sometimes semantics change slightly.
99
100 For example, when the spinlock API was deprecated, spinlock objects ceased
101 to exist, and the whole spinlock API became a synonym for the mutex
102 API -- so code using the spinlock API continued working, but silently
103 switched to mutexes instead. However, if someone relied on
104
105    @code{(typep lock 'spinlock)}
106
107 returning @code{NIL} for a mutexes, trouble could ensue.
108
109 @item @strong{Late Deprecation}
110
111 During late deprecation the interface remains as it was during early
112 deprecation, but the compile-time warning is upgraded to a full
113 warning.
114
115 @item @strong{Final Deprecation}
116
117 During final deprecation the symbols still exist, but using the
118 interface will cause not only the compile-time full warning, but also
119 a runtime error.
120
121 @end enumerate
122
123 After final deprecation the interface is deleted entirely.
124
125 @section List of Deprecated Interfaces
126
127 @subsection Early Deprecation
128
129 @itemize
130
131 @item @strong{SB-EXT:QUIT}
132
133 Deprecated in favor of @code{sb-ext:exit} as of 1.0.56.55 in May 2012.
134 Expected to move into late deprecation in May 2013.
135
136 The design of @code{sb-ext:quit} proved too broken to fix in a
137 backwards-compatible manner, so it had to be deprecated and replaced.
138
139 Problems with it were manifold: when called in the main thread it
140 cause the entire process to exit. When called in another thread with
141 @code{:recklessly-p} it also caused the entire process to exit.
142 However, when called in another thread without @code{:recklessly-p} it
143 instead caused that thread to terminate abnormally without terminating
144 the process. Its behaviour versus other threads than the one it was
145 called in was also underspecified, and dependent on things such as the
146 current session. Any conceivable change that would have made it sane
147 would also have silently broken code that depended on the old
148 behaviour.
149
150 @strong{Remedy}
151
152 For code needing to work with legacy SBCLs, if you were calling
153 @code{quit} with @code{:recklessly-p t}, use
154
155 @sp 1
156 @lisp
157 (defun system-exit (&optional (code 0))
158   (alien-funcall (extern-alien "exit" (function void int)) code))
159 @end lisp
160 @sp 1
161
162 instead. In modern SBCLs simply call either @code{sb-posix:exit} or
163 @code{sb-ext:exit}.
164
165 If you were calling it without @code{:recklessly-p}, be advised
166 that your code may not function as expected when called from threads
167 other than the main one (see above) -- in any case, you can support
168 legacy SBCLs using the following conditionalization:
169
170 @sp 1
171 @lisp
172 (defun lisp-exit (&key (code 0) abort)
173   #+#.(cl:if (cl:find-symbol "EXIT" :sb-ext) '(and) '(or))
174   ;; Assuming process exit is what is desired -- if thread termination
175   ;; is intended, use SB-THREAD:ABORT-THREAD instead.
176   (sb-ext:exit :code code :abort abort)
177   #-#.(cl:if (cl:find-symbol "EXIT" :sb-ext) '(and) '(or))
178   (sb-ext:quit :unix-status code :recklessly-p abort))
179 @end lisp
180 @sp 1
181
182 @sp 1
183 @item @strong{SB-UNIX:UNIX-EXIT}
184
185 Deprecated as of 1.0.56.55 in May 2012. Expected to move into late
186 deprecation in May 2013.
187
188 When the SBCL process termination was refactored as part of changes that
189 led to @code{sb-ext:quit} being deprecated, @code{sb-unix:unix-exit}
190 ceased to be used internally. Since @code{SB-UNIX} is an internal package
191 not intended for user code to use, and since we're slowly in the process
192 of refactoring things to be less Unix-oriented, @code{sb-unix:unix-exit}
193 was initially deleted as it was no longer used. Unfortunately it became
194 apparent that it was used by several external users, so it was re-instated
195 in deprecated form.
196
197 While the cost of keeping @code{sb-unix:unix-exit} indefinitely is
198 trivial, the ability to refactor our internals is important, so its
199 deprecation was taken as an opportunity to highlight that
200 @code{SB-UNIX} is an internal package and @code{SB-POSIX} should be
201 used by user-programs instead -- or alternatively calling the foreign
202 function directly if the desired interface doesn't for some reason
203 exist in @code{SB-POSIX}.
204
205 @strong{Remedy}
206
207 For code needing to work with legacy SBCLs, use e.g. @code{system-exit}
208 as show above in remedies for @code{sb-ext:quit}. In modern SBCLs
209 simply call either @code{sb-posix:exit} or @code{sb-ext:exit} with
210 appropriate arguments.
211
212 @sp 1
213 @item @strong{SB-C::MERGE-TAIL-CALLS Compiler Policy}
214
215 Deprecated as of 1.0.53.74 in November 2011. Expected to move into
216 late deprecation in November 2012.
217
218 This compiler policy was never functional: SBCL has always merged tail
219 calls when it could, regardless of this policy setting. (It was also
220 never officially supported, but several code-bases have historically
221 used it.)
222
223 @strong{Remedy}
224
225 Simply remove the policy declarations. They were never necessary: SBCL
226 always merged tail-calls when possible. To disable tail merging,
227 structure the code to avoid the tail position instead.
228
229 @sp 1
230 @item @strong{Spinlock API}
231
232 Deprecated as of 1.0.53.11 in August 2011. Expected to move into late
233 deprecation in August 2012.
234
235 Spinlocks were an internal interface, but had a number of external users
236 and were hence deprecated instead of being simply deleted.
237
238 Affected symbols: @code{sb-thread::spinlock},
239 @code{sb-thread::make-spinlock}, @code{sb-thread::with-spinlock},
240 @code{sb-thread::with-recursive-spinlock},
241 @code{sb-thread::get-spinlock}, @code{sb-thread::release-spinlock},
242 @code{sb-thread::spinlock-value}, and @code{sb-thread::spinlock-name}.
243
244 @strong{Remedy}
245
246 Use the mutex API instead, or implement spinlocks suiting your needs
247 on top of @code{sb-ext:compare-and-swap},
248 @code{sb-ext:spin-loop-hint}, etc.
249
250 @end itemize
251
252 @subsection Late Deprecation
253
254 @itemize
255
256 @item @strong{SB-THREAD:JOIN-THREAD-ERROR-THREAD and SB-THREAD:INTERRUPT-THREAD-ERROR-THREAD}
257
258 Deprecated in favor of @code{sb-thread:thread-error-thread} as of
259 1.0.29.17 in June 2009. Expected to move into final deprecation in
260 June 2012.
261
262 @strong{Remedy}
263
264 For code that needs to support legacy SBCLs, use e.g.:
265
266 @sp 1
267 @lisp
268 (defun get-thread-error-thread (condition)
269   #+#.(cl:if (cl:find-symbol "THREAD-ERROR-THREAD" :sb-thread)
270              '(and) '(or))
271   (sb-thread:thread-error-thread condition)
272   #-#.(cl:if (cl:find-symbol "THREAD-ERROR-THREAD" :sb-thread)
273              '(and) '(or))
274   (etypecase condition
275    (sb-thread:join-thread-error
276     (sb-thread:join-thread-error-thread condition))
277    (sb-thread:interrupt-thread-error
278     (sb-thread:interrupt-thread-error-thread condition))))
279 @end lisp
280 @sp 1
281
282 @sp 1
283 @item @strong{SB-INTROSPECT:FUNCTION-ARGLIST}
284
285 Deprecated in favor of @code{sb-introspect:function-lambda-list} as of
286 1.0.24.5 in January 2009. Expected to move into final deprecation in
287 January 2012.
288
289 Renamed for consistency and aesthetics. Functions have lambda-lists,
290 not arglists.
291
292 @strong{Remedy}
293
294 For code that needs to support legacy SBCLs, use e.g.:
295
296 @sp 1
297 @lisp
298 (defun get-function-lambda-list (function)
299   #+#.(cl:if (cl:find-symbol "FUNCTION-LAMBDA-LIST" :sb-introspect)
300              '(and) '(or))
301   (sb-introspect:function-lambda-list function)
302   #-#.(cl:if (cl:find-symbol "FUNCTION-LAMBDA-LIST" :sb-introspect)
303              '(and) '(or))
304   (sb-introspect:function-arglist function))
305 @end lisp
306 @sp 1
307
308 @sp 1
309 @item @strong{Stack Allocation Policies}
310
311 Deprecated in favor of @code{sb-ext:*stack-allocate-dynamic-extent*}
312 as of 1.0.19.7 in August 2008, and are expected to be removed in
313 August 2012.
314
315 Affected symbols: @code{sb-c::stack-allocate-dynamic-extent},
316 @code{sb-c::stack-allocate-vector}, and
317 @code{sb-c::stack-allocate-value-cells}.
318
319 These compiler policies were never officially supported, and turned
320 out the be a flawed design.
321
322 @strong{Remedy}
323
324 For code that needs stack-allocation in legacy SBCLs, conditionalize
325 using:
326
327 @sp 1
328 @lisp
329 #-#.(cl:if (cl:find-symbol "*STACK-ALLOCATE-DYNAMIC-EXTENT*" :sb-ext)
330            '(and) '(or))
331 (declare (optimize sb-c::stack-allocate-dynamic-extent))
332 @end lisp
333 @sp 1
334
335 However, unless stack allocation is essential, we recommend simply
336 removing these declarations. Refer to documentation on
337 @code{sb-ext:*stack-allocate-dynamic*} for details on stack allocation
338 control in modern SBCLs.
339
340 @sp 1
341 @item @strong{SB-SYS:OUTPUT-RAW-BYTES}
342
343 Deprecated as of 1.0.8.16 in June 2007. Expected to move into final
344 deprecation in June 2012.
345
346 Internal interface with some external users. Never officially
347 supported, deemed unnecessary in presence of @code{write-sequence} and
348 bivalent streams.
349
350 @strong{Remedy}
351
352 Use streams with element-type @code{(unsigned-byte 8)}
353 or @code{:default} -- the latter allowing both binary and
354 character IO -- in conjunction with @code{write-sequence}.
355
356 @end itemize
357
358 @subsection Final Deprecation
359
360 No interfaces are currently in final deprecation.
361
362 @section Historical Interfaces
363
364 The following is a partial list of interfaces present in historical
365 versions of SBCL, which have since then been deleted.
366
367 @itemize
368
369 @item @strong{SB-KERNEL:INSTANCE-LAMBDA}
370
371 Historically needed for CLOS code. Deprecated as of 0.9.3.32 in August
372 2005. Deleted as of 1.0.47.8 in April 2011. Plain @code{lambda} can be
373 used where @code{sb-kernel:instance-lambda} used to be needed.
374
375 @sp 1
376 @item @strong{SB-ALIEN:DEF-ALIEN-ROUTINE, SB-ALIEN:DEF-ALIEN-VARIABLE, SB-ALIEN:DEF-ALIEN-TYPE}
377
378 Inherited from CMUCL, naming convention not consistent with preferred
379 SBCL style. Deprecated as of 0.pre7.90 in December 2001. Deleted as of
380 1.0.9.17 in September 2007. Replaced by
381 @code{sb-alien:define-alien-routine},
382 @code{sb-alien:define-alien-variable}, and
383 @code{sb-alien:define-alien-type}.
384
385 @end itemize