Move SET-INFO-VALUE's DEFKNOWN into fndb, also fix a style-warning.
[sbcl.git] / doc / manual / deprecated.texinfo
blob609f72be15de8dccef9f8da98d54985dc8507186
1 @node Deprecated Interfaces
2 @comment  node-name,  next,  previous,  up
3 @chapter Deprecated Interfaces
5 This chapter documents the deprecation process used for SBCL
6 interfaces, and lists legacy interfaces in various stages of
7 deprecation.
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.
13 @section Why Deprecate?
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:
19 @itemize
21 @item @strong{Broken Interfaces}
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.
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.
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.
37 @item @strong{Internal Interfaces}
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.
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.
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.
53 When internal interfaces are deprecated we try our best to provide
54 supported alternatives.
56 @item @strong{Aesthetics & Ease of Maintenance}
58 Sometimes an interface isn't broken or internal, but just inconsistent
59 somehow.
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.
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.
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.
76 @end itemize
78 @section What Happens During Deprecation?
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.
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.
88 @enumerate
90 @item @strong{Early Deprecation}
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.
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.
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
105    @code{(typep lock 'spinlock)}
107 returning @code{NIL} for a mutexes, trouble could ensue.
109 @item @strong{Late Deprecation}
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.
115 @item @strong{Final Deprecation}
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.
121 @end enumerate
123 After final deprecation the interface is deleted entirely.
125 @section List of Deprecated Interfaces
127 @subsection Early Deprecation
129 @itemize
131 @item @strong{SOCKINT::WIN32-*}
133 Deprecated in favor of the corresponding prefix-less functions
134 (e.g. @code{sockint::bind} replaces @code{sockint::win32-bind}) as of
135 1.2.10 in March 2015. Expected to move into late deprecation in August
136 2015.
138 @item @strong{SB-EXT:QUIT}
140 Deprecated in favor of @code{sb-ext:exit} as of 1.0.56.55 in May 2012.
141 Expected to move into late deprecation in May 2013.
143 The design of @code{sb-ext:quit} proved too broken to fix in a
144 backwards-compatible manner, so it had to be deprecated and replaced.
146 Problems with it were manifold: when called in the main thread it
147 cause the entire process to exit. When called in another thread with
148 @code{:recklessly-p} it also caused the entire process to exit.
149 However, when called in another thread without @code{:recklessly-p} it
150 instead caused that thread to terminate abnormally without terminating
151 the process. Its behaviour versus other threads than the one it was
152 called in was also underspecified, and dependent on things such as the
153 current session. Any conceivable change that would have made it sane
154 would also have silently broken code that depended on the old
155 behaviour.
157 @strong{Remedy}
159 For code needing to work with legacy SBCLs, if you were calling
160 @code{quit} with @code{:recklessly-p t}, use
162 @sp 1
163 @lisp
164 (defun system-exit (&optional (code 0))
165   (alien-funcall (extern-alien "exit" (function void int)) code))
166 @end lisp
167 @sp 1
169 instead. In modern SBCLs simply call either @code{sb-posix:exit} or
170 @code{sb-ext:exit}.
172 If you were calling it without @code{:recklessly-p}, be advised
173 that your code may not function as expected when called from threads
174 other than the main one (see above) -- in any case, you can support
175 legacy SBCLs using the following conditionalization:
177 @sp 1
178 @lisp
179 (defun lisp-exit (&key (code 0) abort)
180   #+#.(cl:if (cl:find-symbol "EXIT" :sb-ext) '(and) '(or))
181   ;; Assuming process exit is what is desired -- if thread termination
182   ;; is intended, use SB-THREAD:ABORT-THREAD instead.
183   (sb-ext:exit :code code :abort abort)
184   #-#.(cl:if (cl:find-symbol "EXIT" :sb-ext) '(and) '(or))
185   (sb-ext:quit :unix-status code :recklessly-p abort))
186 @end lisp
187 @sp 1
189 @sp 1
190 @item @strong{SB-UNIX:UNIX-EXIT}
192 Deprecated as of 1.0.56.55 in May 2012. Expected to move into late
193 deprecation in May 2013.
195 When the SBCL process termination was refactored as part of changes that
196 led to @code{sb-ext:quit} being deprecated, @code{sb-unix:unix-exit}
197 ceased to be used internally. Since @code{SB-UNIX} is an internal package
198 not intended for user code to use, and since we're slowly in the process
199 of refactoring things to be less Unix-oriented, @code{sb-unix:unix-exit}
200 was initially deleted as it was no longer used. Unfortunately it became
201 apparent that it was used by several external users, so it was re-instated
202 in deprecated form.
204 While the cost of keeping @code{sb-unix:unix-exit} indefinitely is
205 trivial, the ability to refactor our internals is important, so its
206 deprecation was taken as an opportunity to highlight that
207 @code{SB-UNIX} is an internal package and @code{SB-POSIX} should be
208 used by user-programs instead -- or alternatively calling the foreign
209 function directly if the desired interface doesn't for some reason
210 exist in @code{SB-POSIX}.
212 @strong{Remedy}
214 For code needing to work with legacy SBCLs, use e.g. @code{system-exit}
215 as show above in remedies for @code{sb-ext:quit}. In modern SBCLs
216 simply call either @code{sb-posix:exit} or @code{sb-ext:exit} with
217 appropriate arguments.
219 @sp 1
220 @item @strong{SB-C::MERGE-TAIL-CALLS Compiler Policy}
222 Deprecated as of 1.0.53.74 in November 2011. Expected to move into
223 late deprecation in November 2012.
225 This compiler policy was never functional: SBCL has always merged tail
226 calls when it could, regardless of this policy setting. (It was also
227 never officially supported, but several code-bases have historically
228 used it.)
230 @strong{Remedy}
232 Simply remove the policy declarations. They were never necessary: SBCL
233 always merged tail-calls when possible. To disable tail merging,
234 structure the code to avoid the tail position instead.
236 @sp 1
237 @item @strong{Spinlock API}
239 Deprecated as of 1.0.53.11 in August 2011. Expected to move into late
240 deprecation in August 2012.
242 Spinlocks were an internal interface, but had a number of external users
243 and were hence deprecated instead of being simply deleted.
245 Affected symbols: @code{sb-thread::spinlock},
246 @code{sb-thread::make-spinlock}, @code{sb-thread::with-spinlock},
247 @code{sb-thread::with-recursive-spinlock},
248 @code{sb-thread::get-spinlock}, @code{sb-thread::release-spinlock},
249 @code{sb-thread::spinlock-value}, and @code{sb-thread::spinlock-name}.
251 @strong{Remedy}
253 Use the mutex API instead, or implement spinlocks suiting your needs
254 on top of @code{sb-ext:compare-and-swap},
255 @code{sb-ext:spin-loop-hint}, etc.
257 @item @strong{SOCKINT::HANDLE->FD}, @strong{SOCKINT::FD->HANDLE}
259 Internally deprecated in 2012. Declared deprecated as of 1.2.10 in March
260 2015. Expected to move into final deprecation in August 2015.
262 @end itemize
264 @subsection Late Deprecation
266 @itemize
268 @item @strong{SB-THREAD:JOIN-THREAD-ERROR-THREAD and SB-THREAD:INTERRUPT-THREAD-ERROR-THREAD}
270 Deprecated in favor of @code{sb-thread:thread-error-thread} as of
271 1.0.29.17 in June 2009. Expected to move into final deprecation in
272 June 2012.
274 @strong{Remedy}
276 For code that needs to support legacy SBCLs, use e.g.:
278 @sp 1
279 @lisp
280 (defun get-thread-error-thread (condition)
281   #+#.(cl:if (cl:find-symbol "THREAD-ERROR-THREAD" :sb-thread)
282              '(and) '(or))
283   (sb-thread:thread-error-thread condition)
284   #-#.(cl:if (cl:find-symbol "THREAD-ERROR-THREAD" :sb-thread)
285              '(and) '(or))
286   (etypecase condition
287    (sb-thread:join-thread-error
288     (sb-thread:join-thread-error-thread condition))
289    (sb-thread:interrupt-thread-error
290     (sb-thread:interrupt-thread-error-thread condition))))
291 @end lisp
292 @sp 1
294 @sp 1
295 @item @strong{SB-INTROSPECT:FUNCTION-ARGLIST}
297 Deprecated in favor of @code{sb-introspect:function-lambda-list} as of
298 1.0.24.5 in January 2009. Expected to move into final deprecation in
299 January 2012.
301 Renamed for consistency and aesthetics. Functions have lambda-lists,
302 not arglists.
304 @strong{Remedy}
306 For code that needs to support legacy SBCLs, use e.g.:
308 @sp 1
309 @lisp
310 (defun get-function-lambda-list (function)
311   #+#.(cl:if (cl:find-symbol "FUNCTION-LAMBDA-LIST" :sb-introspect)
312              '(and) '(or))
313   (sb-introspect:function-lambda-list function)
314   #-#.(cl:if (cl:find-symbol "FUNCTION-LAMBDA-LIST" :sb-introspect)
315              '(and) '(or))
316   (sb-introspect:function-arglist function))
317 @end lisp
318 @sp 1
320 @sp 1
321 @item @strong{Stack Allocation Policies}
323 Deprecated in favor of @code{sb-ext:*stack-allocate-dynamic-extent*}
324 as of 1.0.19.7 in August 2008, and are expected to be removed in
325 August 2012.
327 Affected symbols: @code{sb-c::stack-allocate-dynamic-extent},
328 @code{sb-c::stack-allocate-vector}, and
329 @code{sb-c::stack-allocate-value-cells}.
331 These compiler policies were never officially supported, and turned
332 out the be a flawed design.
334 @strong{Remedy}
336 For code that needs stack-allocation in legacy SBCLs, conditionalize
337 using:
339 @sp 1
340 @lisp
341 #-#.(cl:if (cl:find-symbol "*STACK-ALLOCATE-DYNAMIC-EXTENT*" :sb-ext)
342            '(and) '(or))
343 (declare (optimize sb-c::stack-allocate-dynamic-extent))
344 @end lisp
345 @sp 1
347 However, unless stack allocation is essential, we recommend simply
348 removing these declarations. Refer to documentation on
349 @code{sb-ext:*stack-allocate-dynamic*} for details on stack allocation
350 control in modern SBCLs.
352 @sp 1
353 @item @strong{SB-SYS:OUTPUT-RAW-BYTES}
355 Deprecated as of 1.0.8.16 in June 2007. Expected to move into final
356 deprecation in June 2012.
358 Internal interface with some external users. Never officially
359 supported, deemed unnecessary in presence of @code{write-sequence} and
360 bivalent streams.
362 @strong{Remedy}
364 Use streams with element-type @code{(unsigned-byte 8)}
365 or @code{:default} -- the latter allowing both binary and
366 character IO -- in conjunction with @code{write-sequence}.
368 @end itemize
370 @subsection Final Deprecation
372 No interfaces are currently in final deprecation.
374 @section Historical Interfaces
376 The following is a partial list of interfaces present in historical
377 versions of SBCL, which have since then been deleted.
379 @itemize
381 @item @strong{SB-KERNEL:INSTANCE-LAMBDA}
383 Historically needed for CLOS code. Deprecated as of 0.9.3.32 in August
384 2005. Deleted as of 1.0.47.8 in April 2011. Plain @code{lambda} can be
385 used where @code{sb-kernel:instance-lambda} used to be needed.
387 @sp 1
388 @item @strong{SB-ALIEN:DEF-ALIEN-ROUTINE, SB-ALIEN:DEF-ALIEN-VARIABLE, SB-ALIEN:DEF-ALIEN-TYPE}
390 Inherited from CMUCL, naming convention not consistent with preferred
391 SBCL style. Deprecated as of 0.pre7.90 in December 2001. Deleted as of
392 1.0.9.17 in September 2007. Replaced by
393 @code{sb-alien:define-alien-routine},
394 @code{sb-alien:define-alien-variable}, and
395 @code{sb-alien:define-alien-type}.
397 @end itemize