1 ;;;; This file defines all the standard functions to be known
2 ;;;; functions. Each function has type and side-effect information,
3 ;;;; and may also have IR1 optimizers.
5 ;;;; This software is part of the SBCL system. See the README file for
8 ;;;; This software is derived from the CMU CL system, which was
9 ;;;; written at Carnegie Mellon University and released into the
10 ;;;; public domain. The software is in the public domain and is
11 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
12 ;;;; files for more information.
16 ;;;; information for known functions:
18 (defknown coerce
(t type-specifier
) t
20 ;; This is not FLUSHABLE because it's defined to signal errors.
22 ;; :DERIVE-TYPE RESULT-TYPE-SPEC-NTH-ARG 2 ? Nope... (COERCE 1 'COMPLEX)
23 ;; returns REAL/INTEGER, not COMPLEX.
25 (defknown list-to-vector
* (list type-specifier
) vector
)
26 (defknown vector-to-vector
* (vector type-specifier
) vector
)
28 (defknown type-of
(t) t
(foldable flushable
))
30 ;;; These can be affected by type definitions, so they're not FOLDABLE.
31 (defknown (sb!xc
:upgraded-complex-part-type sb
!xc
:upgraded-array-element-type
)
32 (type-specifier &optional lexenv-designator
) type-specifier
35 ;;;; from the "Predicates" chapter:
37 ;;; FIXME: Is it right to have TYPEP (and TYPE-OF, elsewhere; and
38 ;;; perhaps SPECIAL-OPERATOR-P and others) be FOLDABLE in the
39 ;;; cross-compilation host? After all, some type relationships (e.g.
40 ;;; FIXNUMness) might be different between host and target. Perhaps
41 ;;; this property should be protected by #-SB-XC-HOST? Perhaps we need
42 ;;; 3-stage bootstrapping after all? (Ugh! It's *so* slow already!)
43 (defknown typep
(t type-specifier
&optional lexenv-designator
) t
44 ;; Unlike SUBTYPEP or UPGRADED-ARRAY-ELEMENT-TYPE and friends, this
45 ;; seems to be FOLDABLE. Like SUBTYPEP, it's affected by type
46 ;; definitions, but unlike SUBTYPEP, there should be no way to make
47 ;; a TYPEP expression with constant arguments which doesn't return
48 ;; an error before the type declaration (because of undefined
49 ;; type). E.g. you can do
50 ;; (SUBTYPEP 'INTEGER 'FOO) => NIL, NIL
52 ;; (SUBTYPEP 'INTEGER 'FOO) => T, T
57 ;; doesn't work because the first call is an error.
59 ;; (UPGRADED-ARRAY-ELEMENT-TYPE and UPGRADED-COMPLEX-PART-TYPE have
60 ;; behavior like SUBTYPEP in this respect, not like TYPEP.)
62 (defknown subtypep
(type-specifier type-specifier
&optional lexenv-designator
)
63 (values boolean boolean
)
64 ;; This is not FOLDABLE because its value is affected by type
67 ;; FIXME: Is it OK to fold this when the types have already been
68 ;; defined? Does the code inherited from CMU CL already do this?
71 (defknown (null symbolp atom consp listp numberp integerp rationalp floatp
72 complexp characterp stringp bit-vector-p vectorp
73 simple-vector-p simple-string-p simple-bit-vector-p arrayp
74 sb
!xc
:packagep functionp compiled-function-p not
)
75 (t) boolean
(movable foldable flushable
))
77 (defknown (eq eql %eql
/integer
) (t t
) boolean
78 (movable foldable flushable commutative
))
79 (defknown (equal equalp
) (t t
) boolean
(foldable flushable recursive
))
81 #!+(or x86 x86-64 arm
)
82 (defknown fixnum-mod-p
(t fixnum
) boolean
83 (movable foldable flushable always-translatable
))
88 (sb!xc
:deftype name-for-class
() t
)
89 (defknown classoid-name
(classoid) symbol
(flushable))
90 (defknown find-classoid
(name-for-class &optional t
)
91 (or classoid null
) ())
92 (defknown classoid-of
(t) classoid
(flushable))
93 (defknown layout-of
(t) layout
(flushable))
94 (defknown copy-structure
(structure-object) structure-object
95 (flushable)) ;; FIXME: can derive the type based on the structure
97 ;;;; from the "Control Structure" chapter:
99 ;;; This is not FLUSHABLE, since it's required to signal an error if
101 (defknown (symbol-value) (symbol) t
())
102 (defknown about-to-modify-symbol-value
(symbol t
&optional t t
) null
104 ;;; From CLHS, "If the symbol is globally defined as a macro or a
105 ;;; special operator, an object of implementation-dependent nature and
106 ;;; identity is returned. If the symbol is not globally defined as
107 ;;; either a macro or a special operator, and if the symbol is fbound,
108 ;;; a function object is returned". Our objects of
109 ;;; implementation-dependent nature happen to be functions.
110 (defknown (symbol-function) (symbol) function
())
112 (defknown boundp
(symbol) boolean
(flushable))
113 (defknown fboundp
((or symbol cons
)) boolean
(unsafely-flushable explicit-check
))
114 (defknown special-operator-p
(symbol) t
115 ;; The set of special operators never changes.
116 (movable foldable flushable
))
117 (defknown set
(symbol t
) t
()
118 :derive-type
#'result-type-last-arg
)
119 (defknown fdefinition
((or symbol cons
)) function
(explicit-check))
120 (defknown %set-fdefinition
((or symbol cons
) function
) function
122 :derive-type
#'result-type-last-arg
)
123 (defknown makunbound
(symbol) symbol
125 :derive-type
#'result-type-first-arg
)
126 (defknown fmakunbound
((or symbol cons
)) (or symbol cons
)
128 :derive-type
#'result-type-first-arg
)
129 (defknown apply
(callable t
&rest t
) *) ; ### Last arg must be List...
130 (defknown funcall
(callable &rest t
) *)
132 (defknown (mapcar maplist
) (callable list
&rest list
) list
135 ;;; According to CLHS the result must be a LIST, but we do not check
137 (defknown (mapcan mapcon
) (callable list
&rest list
) t
140 (defknown (mapc mapl
) (callable list
&rest list
) list
(foldable call
))
142 ;;; We let VALUES-LIST be foldable, since constant-folding will turn
143 ;;; it into VALUES. VALUES is not foldable, since MV constants are
144 ;;; represented by a call to VALUES.
145 (defknown values
(&rest t
) * (movable flushable
))
146 (defknown values-list
(list) * (movable foldable unsafely-flushable
))
148 ;;;; from the "Macros" chapter:
150 (defknown macro-function
(symbol &optional lexenv-designator
)
153 (defknown (macroexpand macroexpand-1 %macroexpand %macroexpand-1
)
154 (t &optional lexenv-designator
)
155 (values form
&optional boolean
))
157 (defknown compiler-macro-function
(t &optional lexenv-designator
)
161 ;;;; from the "Declarations" chapter:
163 (defknown proclaim
(list) (values) (recursive))
165 ;;;; from the "Symbols" chapter:
167 (defknown get
(symbol t
&optional t
) t
(flushable))
168 (defknown sb
!impl
::get3
(symbol t t
) t
(flushable))
169 (defknown remprop
(symbol t
) t
)
170 (defknown symbol-plist
(symbol) list
(flushable))
171 (defknown getf
(list t
&optional t
) t
(foldable flushable
))
172 (defknown get-properties
(list list
) (values t t list
) (foldable flushable
))
173 (defknown symbol-name
(symbol) simple-string
(movable foldable flushable
))
174 (defknown make-symbol
(string) symbol
(flushable))
175 (defknown %make-symbol
(simple-string) symbol
(flushable))
176 (defknown copy-symbol
(symbol &optional t
) symbol
(flushable))
177 (defknown gensym
(&optional
(or string unsigned-byte
)) symbol
())
178 (defknown symbol-package
(symbol) (or sb
!xc
:package null
) (flushable))
179 (defknown keywordp
(t) boolean
(flushable)) ; If someone uninterns it...
181 ;;;; from the "Packages" chapter:
183 (defknown gentemp
(&optional string package-designator
) symbol
)
185 (defknown make-package
(string-designator &key
189 (:internal-symbols index
)
190 (:external-symbols index
))
192 (defknown find-package
(package-designator) (or sb
!xc
:package null
)
194 (defknown find-undeleted-package-or-lose
(package-designator)
195 sb
!xc
:package
) ; not flushable
196 (defknown package-name
(package-designator) (or simple-string null
)
197 (unsafely-flushable))
198 (defknown package-nicknames
(package-designator) list
(unsafely-flushable))
199 (defknown rename-package
(package-designator package-designator
&optional list
)
201 (defknown package-use-list
(package-designator) list
(unsafely-flushable))
202 (defknown package-used-by-list
(package-designator) list
(unsafely-flushable))
203 (defknown package-shadowing-symbols
(package-designator) list
(unsafely-flushable))
204 (defknown list-all-packages
() list
(flushable))
205 (defknown intern
(string &optional package-designator
)
206 (values symbol
(member :internal
:external
:inherited nil
))
208 (defknown find-symbol
(string &optional package-designator
)
209 (values symbol
(member :internal
:external
:inherited nil
))
211 (defknown (export import
) (symbols-designator &optional package-designator
)
213 (defknown unintern
(symbol &optional package-designator
) boolean
)
214 (defknown unexport
(symbols-designator &optional package-designator
) (eql t
))
215 (defknown shadowing-import
(symbols-designator &optional package-designator
)
217 (defknown shadow
((or symbol character string list
) &optional package-designator
)
219 (defknown (use-package unuse-package
)
220 ((or list package-designator
) &optional package-designator
) (eql t
))
221 (defknown find-all-symbols
(string-designator) list
(flushable))
223 (defknown package-iter-step
(fixnum index simple-vector list
)
224 (values fixnum index simple-vector list symbol symbol
))
226 ;;;; from the "Numbers" chapter:
228 (defknown zerop
(number) boolean
(movable foldable flushable explicit-check
))
229 (defknown (plusp minusp
) (real) boolean
230 (movable foldable flushable explicit-check
))
231 (defknown (oddp evenp
) (integer) boolean
232 (movable foldable flushable explicit-check
))
233 (defknown (=) (number &rest number
) boolean
234 (movable foldable flushable explicit-check commutative
))
235 (defknown (/=) (number &rest number
) boolean
236 (movable foldable flushable explicit-check
))
237 (defknown (< > <= >=) (real &rest real
) boolean
238 (movable foldable flushable explicit-check
))
239 (defknown (max min
) (real &rest real
) real
240 (movable foldable flushable explicit-check
))
242 (defknown (+ *) (&rest number
) number
243 (movable foldable flushable explicit-check commutative
))
244 (defknown -
(number &rest number
) number
245 (movable foldable flushable explicit-check
))
246 (defknown / (number &rest number
) number
247 (movable foldable unsafely-flushable explicit-check
))
248 (defknown (1+ 1-
) (number) number
249 (movable foldable flushable explicit-check
))
251 (defknown conjugate
(number) number
252 (movable foldable flushable explicit-check
))
254 (defknown gcd
(&rest integer
) unsigned-byte
255 (movable foldable flushable explicit-check
)
256 #|
:derive-type
'boolean-result-type|
#)
257 (defknown lcm
(&rest integer
) unsigned-byte
258 (movable foldable flushable explicit-check
))
260 #+sb-xc-host
; (See CROSS-FLOAT-INFINITY-KLUDGE.)
261 (defknown exp
(number) irrational
262 (movable foldable flushable explicit-check recursive
)
263 :derive-type
#'result-type-float-contagion
)
265 #-sb-xc-host
; (See CROSS-FLOAT-INFINITY-KLUDGE.)
266 (defknown exp
(number) irrational
267 (movable foldable flushable explicit-check recursive
))
269 (defknown expt
(number number
) number
270 (movable foldable flushable explicit-check recursive
))
271 (defknown log
(number &optional real
) irrational
272 (movable foldable flushable explicit-check recursive
))
273 (defknown sqrt
(number) irrational
274 (movable foldable flushable explicit-check
))
275 (defknown isqrt
(unsigned-byte) unsigned-byte
276 (movable foldable flushable explicit-check recursive
))
278 (defknown (abs phase signum
) (number) number
279 (movable foldable flushable explicit-check
))
280 (defknown cis
(real) (complex float
)
281 (movable foldable flushable explicit-check
))
283 #+sb-xc-host
; (See CROSS-FLOAT-INFINITY-KLUDGE.)
285 (defknown (sin cos
) (number)
286 (or (float -
1.0 1.0) (complex float
))
287 (movable foldable flushable explicit-check recursive
)
288 :derive-type
#'result-type-float-contagion
)
291 (number &optional real
) irrational
292 (movable foldable unsafely-flushable explicit-check recursive
)
293 :derive-type
#'result-type-float-contagion
)
295 (defknown (tan sinh cosh tanh asinh
)
296 (number) irrational
(movable foldable flushable explicit-check recursive
)
297 :derive-type
#'result-type-float-contagion
)
300 #-sb-xc-host
; (See CROSS-FLOAT-INFINITY-KLUDGE.)
302 (defknown (sin cos
) (number)
303 (or (float -
1.0 1.0) (complex float
))
304 (movable foldable flushable explicit-check recursive
))
307 (number &optional real
) irrational
308 (movable foldable unsafely-flushable explicit-check recursive
))
310 (defknown (tan sinh cosh tanh asinh
)
311 (number) irrational
(movable foldable flushable explicit-check recursive
))
314 (defknown (asin acos acosh atanh
)
316 (movable foldable flushable explicit-check recursive
))
318 (defknown float
(real &optional float
) float
319 (movable foldable flushable explicit-check
))
321 (defknown (rational) (real) rational
322 (movable foldable flushable explicit-check
))
324 (defknown (rationalize) (real) rational
325 (movable foldable flushable explicit-check recursive
))
327 (defknown (numerator denominator
) (rational) integer
328 (movable foldable flushable
))
330 (defknown (floor ceiling round
)
331 (real &optional real
) (values integer real
)
332 (movable foldable flushable explicit-check
))
335 (real &optional real
) (values integer real
)
336 (movable foldable flushable explicit-check recursive
))
338 (defknown %multiply-high
(word word
) word
339 (movable foldable flushable
))
341 (defknown (mod rem
) (real real
) real
342 (movable foldable flushable explicit-check
))
344 (defknown (ffloor fceiling fround ftruncate
)
345 (real &optional real
) (values float real
)
346 (movable foldable flushable explicit-check
))
348 (defknown decode-float
(float) (values float float-exponent float
)
349 (movable foldable unsafely-flushable explicit-check
))
350 (defknown scale-float
(float integer
) float
351 (movable foldable unsafely-flushable explicit-check
))
352 (defknown float-radix
(float) float-radix
353 (movable foldable unsafely-flushable
))
354 (defknown float-sign
(float &optional float
) float
355 (movable foldable unsafely-flushable explicit-check
))
356 (defknown (float-digits float-precision
) (float) float-digits
357 (movable foldable unsafely-flushable explicit-check
))
358 (defknown integer-decode-float
(float)
359 (values integer float-int-exponent
(member -
1 1))
360 (movable foldable unsafely-flushable explicit-check
))
362 (defknown complex
(real &optional real
) number
363 (movable foldable flushable explicit-check
))
365 (defknown (realpart imagpart
) (number) real
(movable foldable flushable
))
367 (defknown (logior logxor logand logeqv
) (&rest integer
) integer
368 (movable foldable flushable explicit-check commutative
))
370 (defknown (lognand lognor logandc1 logandc2 logorc1 logorc2
)
371 (integer integer
) integer
372 (movable foldable flushable explicit-check
))
374 (defknown boole
(boole-code integer integer
) integer
375 (movable foldable flushable
))
377 (defknown lognot
(integer) integer
(movable foldable flushable explicit-check
))
378 (defknown logtest
(integer integer
) boolean
(movable foldable flushable commutative
))
379 (defknown logbitp
(unsigned-byte integer
) boolean
(movable foldable flushable
))
380 (defknown ash
(integer integer
) integer
381 (movable foldable flushable explicit-check
))
383 (defknown %ash
/right
((or word sb
!vm
:signed-word
) (mod #.sb
!vm
:n-word-bits
))
384 (or word sb
!vm
:signed-word
)
385 (movable foldable flushable always-translatable
))
386 (defknown (logcount integer-length
) (integer) bit-index
387 (movable foldable flushable explicit-check
))
388 ;;; FIXME: According to the ANSI spec, it's legal to use any
389 ;;; nonnegative indices for BYTE arguments, not just BIT-INDEX. It's
390 ;;; hard to come up with useful ways to do this, but it is possible to
391 ;;; come up with *legal* ways to do this, so it would be nice
392 ;;; to fix this so we comply with the spec.
393 (defknown byte
(bit-index bit-index
) byte-specifier
394 (movable foldable flushable
))
395 (defknown (byte-size byte-position
) (byte-specifier) bit-index
396 (movable foldable flushable
))
397 (defknown ldb
(byte-specifier integer
) unsigned-byte
(movable foldable flushable
))
398 (defknown ldb-test
(byte-specifier integer
) boolean
399 (movable foldable flushable
))
400 (defknown mask-field
(byte-specifier integer
) unsigned-byte
401 (movable foldable flushable
))
402 (defknown dpb
(integer byte-specifier integer
) integer
403 (movable foldable flushable
))
404 (defknown deposit-field
(integer byte-specifier integer
) integer
405 (movable foldable flushable
))
406 (defknown random
((or (float (0.0
)) (integer 1)) &optional random-state
)
407 (or (float 0.0) (integer 0))
409 (defknown make-random-state
(&optional
(or random-state
(member nil t
)))
410 random-state
(flushable))
411 ;; The arg type specifier is for documentation only- EXPLICIT-CHECK prevails.
412 ;; It feels almost wrong to state it at all.
413 (defknown seed-random-state
(&optional
; SBCL extension
414 (or (member nil t
) random-state unsigned-byte
415 (simple-array (unsigned-byte 8) (*))
416 (simple-array (unsigned-byte 32) (*))))
417 random-state
(flushable explicit-check
))
419 (defknown random-state-p
(t) boolean
(movable foldable flushable
))
421 ;;;; from the "Characters" chapter:
422 (defknown (standard-char-p graphic-char-p alpha-char-p
423 upper-case-p lower-case-p both-case-p alphanumericp
)
424 (character) boolean
(movable foldable flushable
))
426 (defknown digit-char-p
(character &optional
(integer 2 36))
427 (or (integer 0 35) null
) (movable foldable flushable
))
429 ;; Character predicates: if the 2-argument predicate which underlies
430 ;; the N-argument predicate unavoidably type-checks its 2 args,
431 ;; then the N-argument form should not type-check anything
432 ;; except in the degenerate case of 1 actual argument.
433 ;; All of the case-sensitive functions have the check of the first arg
434 ;; generated by the compiler, and successive args checked by hand.
435 ;; The case-insensitive functions don't need any checks, since the underlying
436 ;; two-arg case-insensitive function does it, except when it isn't called.
438 (character &rest character
) boolean
(movable foldable flushable commutative
))
440 (defknown (char/= char
< char
> char
<= char
>= char-not-equal
)
441 (character &rest character
) boolean
(movable foldable flushable
))
442 (defknown (char-equal char-lessp char-greaterp char-not-greaterp char-not-lessp
)
443 (character &rest character
) boolean
(movable foldable flushable explicit-check
))
445 (defknown (two-arg-char-equal)
446 (character character
) boolean
(movable foldable flushable commutative
))
448 (defknown (two-arg-char-not-equal
450 two-arg-char-not-lessp
451 two-arg-char-greaterp
452 two-arg-char-not-greaterp
)
453 (character character
) boolean
(movable foldable flushable
))
455 (defknown char-equal-constant
(character character character
)
457 (movable foldable flushable explicit-check
))
459 (defknown character
(t) character
(movable foldable unsafely-flushable
))
460 (defknown char-code
(character) char-code
(movable foldable flushable
))
461 (defknown (char-upcase char-downcase
) (character) character
462 (movable foldable flushable
))
463 (defknown digit-char
(unsigned-byte &optional
(integer 2 36))
464 (or character null
) (movable foldable flushable
))
465 (defknown char-int
(character) char-code
(movable foldable flushable
))
466 (defknown char-name
(character) (or simple-string null
)
467 (movable foldable flushable
))
468 (defknown name-char
(string-designator) (or character null
)
469 (movable foldable flushable
))
470 (defknown code-char
(char-code) character
471 ;; By suppressing constant folding on CODE-CHAR when the
472 ;; cross-compiler is running in the cross-compilation host vanilla
473 ;; ANSI Common Lisp, we can use CODE-CHAR expressions to delay until
474 ;; target Lisp run time the generation of CHARACTERs which aren't
475 ;; STANDARD-CHARACTERs. That way, we don't need to rely on the host
476 ;; Common Lisp being able to handle any characters other than those
477 ;; guaranteed by the ANSI spec.
478 (movable #-sb-xc-host foldable flushable
))
480 ;;;; from the "Sequences" chapter:
482 (defknown elt
(sequence index
) t
(foldable unsafely-flushable
))
484 (defknown subseq
(sequence index
&optional sequence-end
) consed-sequence
486 :derive-type
(sequence-result-nth-arg 1))
488 (defknown copy-seq
(sequence) consed-sequence
(flushable)
489 :derive-type
(sequence-result-nth-arg 1))
491 (defknown length
(sequence) index
(explicit-check foldable flushable dx-safe
))
493 (defknown reverse
(sequence) consed-sequence
(explicit-check flushable
)
494 :derive-type
(sequence-result-nth-arg 1))
496 (defknown nreverse
(sequence) sequence
(explicit-check important-result
)
497 :derive-type
#'result-type-first-arg
498 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
500 (defknown make-sequence
(type-specifier index
502 (:initial-element t
))
505 :derive-type
(creation-result-type-specifier-nth-arg 1))
507 (defknown concatenate
(type-specifier &rest sequence
) consed-sequence
509 :derive-type
(creation-result-type-specifier-nth-arg 1))
511 (defknown %concatenate-to-string
(&rest sequence
) simple-string
512 (explicit-check flushable
))
513 (defknown %concatenate-to-base-string
(&rest sequence
) simple-base-string
514 (explicit-check flushable
))
516 (defknown (map %map
) (type-specifier callable sequence
&rest sequence
)
519 ; :DERIVE-TYPE 'TYPE-SPEC-ARG1 ? Nope... (MAP NIL ...) returns NULL, not NIL.
521 (defknown %map-for-effect-arity-1
(callable sequence
) null
(call))
522 (defknown %map-to-list-arity-1
(callable sequence
) list
(flushable call
))
523 (defknown %map-to-simple-vector-arity-1
(callable sequence
) simple-vector
526 (defknown map-into
(sequence callable
&rest sequence
)
529 :derive-type
#'result-type-first-arg
530 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
532 ;;; returns the result from the predicate...
533 (defknown some
(callable sequence
&rest sequence
) t
534 (foldable unsafely-flushable call
))
536 (defknown (every notany notevery
) (callable sequence
&rest sequence
) boolean
537 (foldable unsafely-flushable call
))
539 (defknown reduce
(callable sequence
&rest t
&key
(:from-end t
) (:start index
)
540 (:end sequence-end
) (:initial-value t
) (:key callable
))
542 (foldable flushable call
))
544 (defknown fill
(sequence t
&rest t
&key
545 (:start index
) (:end sequence-end
)) sequence
547 :derive-type
#'result-type-first-arg
548 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1)
551 (defknown replace
(sequence sequence
&rest t
&key
(:start1 index
)
552 (:end1 sequence-end
) (:start2 index
) (:end2 sequence-end
))
554 :derive-type
#'result-type-first-arg
555 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1)
559 (t sequence
&rest t
&key
(:from-end t
) (:test callable
)
560 (:test-not callable
) (:start index
) (:end sequence-end
)
561 (:count sequence-count
) (:key callable
))
564 :derive-type
(sequence-result-nth-arg 2))
567 (t t sequence
&rest t
&key
(:from-end t
) (:test callable
)
568 (:test-not callable
) (:start index
) (:end sequence-end
)
569 (:count sequence-count
) (:key callable
))
572 :derive-type
(sequence-result-nth-arg 3))
574 (defknown (remove-if remove-if-not
)
575 (callable sequence
&rest t
&key
(:from-end t
) (:start index
)
576 (:end sequence-end
) (:count sequence-count
) (:key callable
))
579 :derive-type
(sequence-result-nth-arg 2))
581 (defknown (substitute-if substitute-if-not
)
582 (t callable sequence
&rest t
&key
(:from-end t
) (:start index
)
583 (:end sequence-end
) (:count sequence-count
) (:key callable
))
586 :derive-type
(sequence-result-nth-arg 3))
589 (t sequence
&rest t
&key
(:from-end t
) (:test callable
)
590 (:test-not callable
) (:start index
) (:end sequence-end
)
591 (:count sequence-count
) (:key callable
))
593 (flushable call important-result
)
594 :derive-type
(sequence-result-nth-arg 2)
595 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 2))
597 (defknown nsubstitute
598 (t t sequence
&rest t
&key
(:from-end t
) (:test callable
)
599 (:test-not callable
) (:start index
) (:end sequence-end
)
600 (:count sequence-count
) (:key callable
))
603 :derive-type
(sequence-result-nth-arg 3)
604 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 3))
606 (defknown (delete-if delete-if-not
)
607 (callable sequence
&rest t
&key
(:from-end t
) (:start index
)
608 (:end sequence-end
) (:count sequence-count
) (:key callable
))
610 (flushable call important-result
)
611 :derive-type
(sequence-result-nth-arg 2)
612 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 2))
614 (defknown (nsubstitute-if nsubstitute-if-not
)
615 (t callable sequence
&rest t
&key
(:from-end t
) (:start index
)
616 (:end sequence-end
) (:count sequence-count
) (:key callable
))
619 :derive-type
(sequence-result-nth-arg 3)
620 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 3))
622 (defknown remove-duplicates
623 (sequence &rest t
&key
(:test callable
) (:test-not callable
) (:start index
)
624 (:from-end t
) (:end sequence-end
) (:key callable
))
626 (unsafely-flushable call
)
627 :derive-type
(sequence-result-nth-arg 1))
629 (defknown delete-duplicates
630 (sequence &rest t
&key
(:test callable
) (:test-not callable
) (:start index
)
631 (:from-end t
) (:end sequence-end
) (:key callable
))
633 (unsafely-flushable call important-result
)
634 :derive-type
(sequence-result-nth-arg 1)
635 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
637 (defknown find
(t sequence
&rest t
&key
(:test callable
)
638 (:test-not callable
) (:start index
) (:from-end t
)
639 (:end sequence-end
) (:key callable
))
641 (foldable flushable call
))
643 (defknown (find-if find-if-not
)
644 (callable sequence
&rest t
&key
(:from-end t
) (:start index
)
645 (:end sequence-end
) (:key callable
))
647 (foldable flushable call
))
649 (defknown position
(t sequence
&rest t
&key
(:test callable
)
650 (:test-not callable
) (:start index
) (:from-end t
)
651 (:end sequence-end
) (:key callable
))
653 (foldable flushable call
)
654 :derive-type
#'position-derive-type
)
656 (defknown (position-if position-if-not
)
657 (callable sequence
&rest t
&key
(:from-end t
) (:start index
)
658 (:end sequence-end
) (:key callable
))
660 (foldable flushable call
)
661 :derive-type
#'position-derive-type
)
663 (defknown count
(t sequence
&rest t
&key
664 (:test callable
) (:test-not callable
) (:start index
)
665 (:from-end t
) (:end sequence-end
) (:key callable
))
667 (foldable flushable call
)
668 :derive-type
#'count-derive-type
)
670 (defknown (count-if count-if-not
)
671 (callable sequence
&rest t
&key
672 (:from-end t
) (:start index
) (:end sequence-end
) (:key callable
))
674 (foldable flushable call
)
675 :derive-type
#'count-derive-type
)
677 (defknown (mismatch search
)
678 (sequence sequence
&rest t
&key
(:from-end t
) (:test callable
)
679 (:test-not callable
) (:start1 index
) (:end1 sequence-end
)
680 (:start2 index
) (:end2 sequence-end
) (:key callable
))
682 (foldable flushable call
))
684 ;;; not FLUSHABLE, since vector sort guaranteed in-place...
685 (defknown (stable-sort sort
) (sequence callable
&rest t
&key
(:key callable
))
688 :derive-type
(sequence-result-nth-arg 1)
689 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
690 (defknown sb
!impl
::stable-sort-list
(list function function
) list
691 (call important-result explicit-check
)
692 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
693 (defknown sb
!impl
::sort-vector
(vector index index function
(or function null
))
694 * ; SORT-VECTOR works through side-effect
696 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
698 (defknown sb
!impl
::stable-sort-vector
699 (vector function
(or function null
))
701 (call explicit-check
)
702 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
704 (defknown sb
!impl
::stable-sort-simple-vector
705 (simple-vector function
(or function null
))
707 (call explicit-check
)
708 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
710 (defknown merge
(type-specifier sequence sequence callable
711 &key
(:key callable
))
713 (call important-result
)
714 :derive-type
(creation-result-type-specifier-nth-arg 1)
715 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 2 3))
717 (defknown read-sequence
(sequence stream
724 (defknown write-sequence
(sequence stream
730 :derive-type
#'result-type-first-arg
)
732 ;;;; from the "Manipulating List Structure" chapter:
733 (defknown (car cdr first rest
)
736 (foldable flushable
))
738 ;; Correct argument type restrictions for these functions are
739 ;; complicated, so we just declare them to accept LISTs and suppress
740 ;; flushing is safe code.
741 (defknown (caar cadr cdar cddr
742 caaar caadr cadar caddr cdaar cdadr cddar cdddr
743 caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
744 cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
745 second third fourth fifth sixth seventh eighth ninth tenth
)
748 (foldable unsafely-flushable
))
750 (defknown cons
(t t
) cons
(movable flushable
))
752 (defknown tree-equal
(t t
&key
(:test callable
) (:test-not callable
)) boolean
753 (foldable flushable call
))
754 (defknown endp
(list) boolean
(foldable flushable movable
))
755 (defknown list-length
(list) (or index null
) (foldable unsafely-flushable
))
756 (defknown (nth fast-
&rest-nth
) (unsigned-byte list
) t
(foldable flushable
))
757 (defknown nthcdr
(unsigned-byte list
) t
(foldable unsafely-flushable
))
759 (defknown last
(list &optional unsigned-byte
) t
(foldable flushable
))
760 (defknown %last0
(list) t
(foldable flushable
))
761 (defknown %last1
(list) t
(foldable flushable
))
762 (defknown %lastn
/fixnum
(list (and unsigned-byte fixnum
)) t
(foldable flushable
))
763 (defknown %lastn
/bignum
(list (and unsigned-byte bignum
)) t
(foldable flushable
))
765 (defknown list
(&rest t
) list
(movable flushable
))
766 (defknown list
* (t &rest t
) t
(movable flushable
))
767 (defknown make-list
(index &key
(:initial-element t
)) list
770 (defknown sb
!impl
::|List|
(&rest t
) list
(movable flushable foldable
))
771 (defknown sb
!impl
::|List
*|
(t &rest t
) t
(movable flushable foldable
))
772 (defknown sb
!impl
::|Append|
(&rest t
) t
(flushable foldable
))
773 (defknown sb
!impl
::|Vector|
(&rest t
) simple-vector
(flushable foldable
))
775 ;;; All but last must be of type LIST, but there seems to be no way to
776 ;;; express that in this syntax.
777 (defknown append
(&rest t
) t
(flushable))
778 (defknown sb
!impl
::append2
(list t
) t
(flushable))
780 (defknown copy-list
(list) list
(flushable))
781 (defknown copy-alist
(list) list
(flushable))
782 (defknown copy-tree
(t) t
(flushable recursive
))
783 (defknown revappend
(list t
) t
(flushable))
785 ;;; All but last must be of type LIST, but there seems to be no way to
786 ;;; express that in this syntax. The result must be LIST, but we do
787 ;;; not check it now :-).
788 (defknown nconc
(&rest t
) t
()
789 :destroyed-constant-args
(remove-non-constants-and-nils #'butlast
))
791 (defknown nreconc
(list t
) t
(important-result)
792 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
793 (defknown butlast
(list &optional unsigned-byte
) list
(flushable))
794 (defknown nbutlast
(list &optional unsigned-byte
) list
()
795 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
797 (defknown ldiff
(list t
) list
(flushable))
798 (defknown (rplaca rplacd
) (cons t
) cons
()
799 :destroyed-constant-args
(nth-constant-args 1))
801 (defknown subst
(t t t
&key
(:key callable
) (:test callable
)
802 (:test-not callable
))
804 (defknown nsubst
(t t t
&key
(:key callable
) (:test callable
)
805 (:test-not callable
))
807 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 3))
809 (defknown (subst-if subst-if-not
)
810 (t callable t
&key
(:key callable
))
812 (defknown (nsubst-if nsubst-if-not
)
813 (t callable t
&key
(:key callable
))
815 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 3))
817 (defknown sublis
(list t
&key
(:key callable
) (:test callable
)
818 (:test-not callable
))
820 (defknown nsublis
(list t
&key
(:key callable
) (:test callable
)
821 (:test-not callable
))
823 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 2))
825 (defknown member
(t list
&key
(:key callable
) (:test callable
)
826 (:test-not callable
))
827 list
(foldable flushable call
))
828 (defknown (member-if member-if-not
) (callable list
&key
(:key callable
))
829 list
(foldable flushable call
))
831 (defknown tailp
(t list
) boolean
(foldable flushable
))
833 (defknown adjoin
(t list
&key
(:key callable
) (:test callable
)
834 (:test-not callable
))
835 cons
(flushable call
))
837 (defknown (union intersection set-difference set-exclusive-or
)
838 (list list
&key
(:key callable
) (:test callable
) (:test-not callable
))
840 (foldable flushable call
))
842 (defknown (nunion nintersection nset-difference nset-exclusive-or
)
843 (list list
&key
(:key callable
) (:test callable
) (:test-not callable
))
845 (foldable flushable call important-result
)
846 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1 2))
849 (list list
&key
(:key callable
) (:test callable
) (:test-not callable
))
851 (foldable flushable call
))
853 (defknown acons
(t t t
) cons
(movable flushable
))
854 (defknown pairlis
(t t
&optional t
) list
(flushable))
856 (defknown (rassoc assoc
)
857 (t list
&key
(:key callable
) (:test callable
) (:test-not callable
))
858 list
(foldable flushable call
))
859 (defknown (assoc-if-not assoc-if rassoc-if rassoc-if-not
)
860 (callable list
&key
(:key callable
)) list
(foldable flushable call
))
862 (defknown (memq assq
) (t list
) list
(foldable flushable
))
863 (defknown delq
(t list
) list
(flushable)
864 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 2))
866 ;;;; from the "Hash Tables" chapter:
868 (defknown make-hash-table
869 (&key
(:test callable
) (:size unsigned-byte
)
870 (:rehash-size
(or (integer 1) (float (1.0
))))
871 (:rehash-threshold
(real 0 1))
872 (:hash-function
(or null callable
))
873 (:weakness
(member nil
:key
:value
:key-and-value
:key-or-value
))
877 (defknown hash-table-p
(t) boolean
(movable foldable flushable
))
878 (defknown gethash
(t hash-table
&optional t
) (values t boolean
)
879 (flushable)) ; not FOLDABLE, since hash table contents can change
880 (defknown sb
!impl
::gethash3
(t hash-table t
) (values t boolean
)
881 (flushable)) ; not FOLDABLE, since hash table contents can change
882 (defknown %puthash
(t hash-table t
) t
()
883 :destroyed-constant-args
(nth-constant-args 2)
884 :derive-type
#'result-type-last-arg
)
885 (defknown remhash
(t hash-table
) boolean
()
886 :destroyed-constant-args
(nth-constant-args 2))
887 (defknown maphash
(callable hash-table
) null
(flushable call
))
888 (defknown clrhash
(hash-table) hash-table
()
889 :destroyed-constant-args
(nth-constant-args 2))
890 (defknown hash-table-count
(hash-table) index
(flushable))
891 (defknown hash-table-rehash-size
(hash-table) (or index
(single-float (1.0
)))
892 (foldable flushable
))
893 (defknown hash-table-rehash-threshold
(hash-table) (single-float (0.0
) 1.0)
894 (foldable flushable
))
895 (defknown hash-table-size
(hash-table) index
(flushable))
896 (defknown hash-table-test
(hash-table) symbol
(foldable flushable
))
897 (defknown sxhash
(t) hash
(#-sb-xc-host foldable flushable
))
898 (defknown psxhash
(t &optional t
) hash
(#-sb-xc-host foldable flushable
))
899 (defknown hash-table-equalp
(hash-table hash-table
) boolean
(foldable flushable
))
901 ;;;; from the "Arrays" chapter
903 (defknown make-array
((or index list
)
905 (:element-type type-specifier
)
907 (:initial-contents t
)
909 ;; the type constraint doesn't do anything
910 ;; on account of EXPLICIT-CHECK. it's documentation.
911 (:fill-pointer
(or index boolean
))
912 (:displaced-to
(or array null
))
913 (:displaced-index-offset index
))
914 array
(flushable explicit-check
))
916 (defknown %make-array
((or index list
)
917 (unsigned-byte #.sb
!vm
:n-widetag-bits
)
920 (:element-type type-specifier
)
922 (:initial-contents t
)
924 (:fill-pointer
(or index boolean
))
925 (:displaced-to
(or array null
))
926 (:displaced-index-offset index
))
929 (defknown sb
!impl
::fill-data-vector
(vector list sequence
)
933 (defknown vector
(&rest t
) simple-vector
(flushable))
935 (defknown aref
(array &rest index
) t
(foldable))
936 (defknown row-major-aref
(array index
) t
(foldable))
938 (defknown array-element-type
(array)
940 (foldable flushable recursive
))
941 (defknown array-rank
(array) array-rank
(foldable flushable
))
942 ;; FIXME: there's a fencepost bug, but for all practical purposes our
943 ;; ARRAY-RANK-LIMIT is infinite, thus masking the bug. e.g. if the
944 ;; exclusive limit on rank were 8, then your dimension numbers can
945 ;; be in the range 0 through 6, not 0 through 7.
946 (defknown array-dimension
(array array-rank
) index
(foldable flushable
))
947 (defknown array-dimensions
(array) list
(foldable flushable
))
948 (defknown array-in-bounds-p
(array &rest integer
) boolean
(foldable flushable
))
949 (defknown array-row-major-index
(array &rest index
) array-total-size
950 (foldable flushable
))
951 (defknown array-total-size
(array) array-total-size
(foldable flushable
))
952 (defknown adjustable-array-p
(array) boolean
(movable foldable flushable
))
954 (defknown svref
(simple-vector index
) t
(foldable flushable
))
955 (defknown bit
((array bit
) &rest index
) bit
(foldable flushable
))
956 (defknown sbit
((simple-array bit
) &rest index
) bit
(foldable flushable
))
958 ;;; FIXME: :DESTROYED-CONSTANT-ARGS for these is complicated.
959 (defknown (bit-and bit-ior bit-xor bit-eqv bit-nand bit-nor bit-andc1 bit-andc2
961 ((array bit
) (array bit
) &optional
(or (array bit
) (member t nil
)))
964 #|
:derive-type
#'result-type-last-arg|
#)
966 (defknown bit-not
((array bit
) &optional
(or (array bit
) (member t nil
)))
969 #|
:derive-type
#'result-type-last-arg|
#)
971 (defknown bit-vector-
= (bit-vector bit-vector
) boolean
972 (movable foldable flushable
))
974 (defknown array-has-fill-pointer-p
(array) boolean
975 (movable foldable flushable
))
976 (defknown fill-pointer
(complex-vector) index
977 (unsafely-flushable explicit-check
))
978 (defknown sb
!impl
::fill-pointer-error
(t &optional t
) nil
)
980 (defknown vector-push
(t complex-vector
) (or index null
)
982 :destroyed-constant-args
(nth-constant-args 2))
983 (defknown vector-push-extend
(t complex-vector
&optional
(and index
(integer 1))) index
985 :destroyed-constant-args
(nth-constant-args 2))
986 (defknown vector-pop
(complex-vector) t
988 :destroyed-constant-args
(nth-constant-args 1))
990 ;;; FIXME: complicated :DESTROYED-CONSTANT-ARGS
991 ;;; Also, an important-result warning could be provided if the array
992 ;;; is known to be not expressly adjustable.
993 (defknown adjust-array
994 (array (or index list
) &key
(:element-type type-specifier
)
995 (:initial-element t
) (:initial-contents t
)
996 (:fill-pointer
(or index boolean
))
997 (:displaced-to
(or array null
))
998 (:displaced-index-offset index
))
1000 ; :derive-type 'result-type-arg1) Not even close...
1002 ;;;; from the "Strings" chapter:
1004 (defknown char
(string index
) character
(foldable flushable
))
1005 (defknown schar
(simple-string index
) character
(foldable flushable
))
1007 (defknown (string= string-equal
)
1008 (string-designator string-designator
&key
(:start1 index
) (:end1 sequence-end
)
1009 (:start2 index
) (:end2 sequence-end
))
1011 (foldable flushable
))
1013 (defknown (string< string
> string
<= string
>= string
/= string-lessp
1014 string-greaterp string-not-lessp string-not-greaterp
1016 (string-designator string-designator
&key
(:start1 index
) (:end1 sequence-end
)
1017 (:start2 index
) (:end2 sequence-end
))
1019 (foldable flushable
))
1021 (defknown make-string
(index &key
(:element-type type-specifier
)
1022 (:initial-element character
))
1023 simple-string
(flushable))
1025 (defknown (string-trim string-left-trim string-right-trim
)
1026 (sequence string-designator
) string
(flushable))
1028 (defknown (string-upcase string-downcase string-capitalize
)
1029 (string-designator &key
(:start index
) (:end sequence-end
))
1030 simple-string
(flushable))
1032 (defknown (nstring-upcase nstring-downcase nstring-capitalize
)
1033 (string &key
(:start index
) (:end sequence-end
))
1035 :destroyed-constant-args
(nth-constant-nonempty-sequence-args 1))
1037 (defknown string
(string-designator) string
1038 (flushable explicit-check
))
1040 ;;;; internal non-keyword versions of string predicates:
1042 (defknown (string<* string
>* string
<=* string
>=* string
/=*)
1043 (string-designator string-designator index sequence-end index sequence-end
)
1045 (foldable flushable
))
1048 (string-designator string-designator index sequence-end index sequence-end
)
1050 (foldable flushable
))
1052 ;;;; from the "Eval" chapter:
1054 (defknown eval
(t) * (recursive))
1055 (defknown constantp
(t &optional lexenv-designator
) boolean
1056 (foldable flushable
))
1058 ;;;; from the "Streams" chapter:
1060 (defknown make-synonym-stream
(symbol) stream
(flushable))
1061 (defknown make-broadcast-stream
(&rest stream
) stream
(unsafely-flushable))
1062 (defknown make-concatenated-stream
(&rest stream
) stream
(unsafely-flushable))
1063 (defknown make-two-way-stream
(stream stream
) stream
(unsafely-flushable))
1064 (defknown make-echo-stream
(stream stream
) stream
(flushable))
1065 (defknown make-string-input-stream
(string &optional index sequence-end
)
1068 (defknown make-string-output-stream
1069 (&key
(:element-type type-specifier
))
1070 string-output-stream
1072 (defknown get-output-stream-string
(stream) simple-string
())
1073 (defknown streamp
(t) boolean
(movable foldable flushable
))
1074 (defknown stream-element-type
(stream) type-specifier
1075 (movable foldable flushable
))
1076 (defknown stream-external-format
(stream) t
(flushable))
1077 (defknown (output-stream-p input-stream-p
) (stream) boolean
1078 (movable foldable flushable
))
1079 (defknown open-stream-p
(stream) boolean
(flushable))
1080 (defknown close
(stream &key
(:abort t
)) (eql t
) ())
1081 (defknown file-string-length
(ansi-stream (or string character
))
1082 (or unsigned-byte null
)
1085 ;;;; from the "Input/Output" chapter:
1087 ;;; (The I/O functions are given effects ANY under the theory that
1088 ;;; code motion over I/O operations is particularly confusing and not
1089 ;;; very important for efficiency.)
1091 (defknown copy-readtable
(&optional
(or readtable null
) (or readtable null
))
1094 (defknown readtablep
(t) boolean
(movable foldable flushable
))
1096 (defknown set-syntax-from-char
1097 (character character
&optional readtable
(or readtable null
)) (eql t
)
1100 (defknown set-macro-character
(character callable
&optional t
(or readtable null
))
1103 (defknown get-macro-character
(character &optional
(or readtable null
))
1104 (values callable boolean
) (flushable))
1106 (defknown make-dispatch-macro-character
(character &optional t readtable
)
1108 (defknown set-dispatch-macro-character
1109 (character character callable
&optional
(or readtable null
)) (eql t
)
1111 (defknown get-dispatch-macro-character
1112 (character character
&optional
(or readtable null
)) (or callable null
)
1115 (defknown copy-pprint-dispatch
1116 (&optional
(or sb
!pretty
:pprint-dispatch-table null
))
1117 sb
!pretty
:pprint-dispatch-table
1119 (defknown pprint-dispatch
1120 (t &optional
(or sb
!pretty
:pprint-dispatch-table null
))
1121 (values callable boolean
)
1123 (defknown (pprint-fill pprint-linear
)
1124 (stream-designator t
&optional t t
)
1127 (defknown pprint-tabular
1128 (stream-designator t
&optional t t unsigned-byte
)
1131 (defknown pprint-indent
1132 ((member :block
:current
) real
&optional stream-designator
)
1135 (defknown pprint-newline
1136 ((member :linear
:fill
:miser
:mandatory
) &optional stream-designator
)
1139 (defknown pprint-tab
1140 ((member :line
:section
:line-relative
:section-relative
)
1141 unsigned-byte unsigned-byte
&optional stream-designator
)
1144 (defknown set-pprint-dispatch
1145 (type-specifier (or null callable
)
1146 &optional real sb
!pretty
:pprint-dispatch-table
)
1150 ;;; may return any type due to eof-value...
1151 ;;; and because READ generally returns anything.
1152 (defknown (read read-preserving-whitespace
)
1153 (&optional stream-designator t t t
) t
(explicit-check))
1155 (defknown read-char
(&optional stream-designator t t t
) t
(explicit-check)
1156 :derive-type
(read-elt-type-deriver nil
'character nil
))
1157 (defknown read-char-no-hang
(&optional stream-designator t t t
) t
1159 :derive-type
(read-elt-type-deriver nil
'character t
))
1161 (defknown read-delimited-list
(character &optional stream-designator t
) list
1163 ;; FIXME: add a type-deriver => (values (or string eof-value) boolean)
1164 (defknown read-line
(&optional stream-designator t t t
) (values t boolean
)
1166 (defknown unread-char
(character &optional stream-designator
) t
1168 (defknown peek-char
(&optional
(or character
(member nil t
))
1169 stream-designator t t t
) t
1171 :derive-type
(read-elt-type-deriver t
'character nil
))
1173 (defknown listen
(&optional stream-designator
) boolean
(flushable explicit-check
))
1175 (defknown clear-input
(&optional stream-designator
) null
(explicit-check))
1177 (defknown read-from-string
1178 (string &optional t t
1182 (:preserve-whitespace t
))
1184 (defknown parse-integer
1188 (:radix
(integer 2 36))
1190 (values (or integer null
()) index
))
1192 (defknown read-byte
(stream &optional t t
) t
(explicit-check)
1193 :derive-type
(read-elt-type-deriver nil
'integer nil
))
1195 (defknown (prin1 print princ
) (t &optional stream-designator
)
1197 (any explicit-check
)
1198 :derive-type
#'result-type-first-arg
)
1200 (defknown output-object
(t stream
)
1202 (any explicit-check
))
1204 (defknown (pprint) (t &optional stream-designator
) (values)
1208 ((deffrob (name keys returns attributes
&rest more
)
1213 (:base
(integer 2 36))
1217 (:level
(or unsigned-byte null
))
1218 (:length
(or unsigned-byte null
))
1222 (:lines
(or unsigned-byte null
))
1223 (:right-margin
(or unsigned-byte null
))
1224 (:miser-width
(or unsigned-byte null
))
1225 (:pprint-dispatch t
)
1226 (:suppress-errors t
))
1227 ,returns
,attributes
,@more
)))
1228 (deffrob write
((:stream stream-designator
)) t
(any explicit-check
)
1229 :derive-type
#'result-type-first-arg
)
1230 ;;; xxx-TO-STRING functions are not foldable because they depend on
1231 ;;; the dynamic environment, the state of the pretty printer dispatch
1232 ;;; table, and probably other run-time factors.
1233 (deffrob write-to-string
() simple-string
1234 (unsafely-flushable explicit-check
)))
1236 (defknown (prin1-to-string princ-to-string
) (t) simple-string
(flushable))
1237 (defknown sb
!impl
::stringify-object
(t) simple-string
)
1239 (defknown write-char
(character &optional stream-designator
) character
1241 :derive-type
#'result-type-first-arg
)
1243 (defknown (write-string write-line
)
1244 (string &optional stream-designator
&key
(:start index
) (:end sequence-end
))
1247 :derive-type
#'result-type-first-arg
)
1249 (defknown (terpri finish-output force-output clear-output
)
1250 (&optional stream-designator
) null
1253 (defknown fresh-line
(&optional stream-designator
) boolean
1256 (defknown write-byte
(integer stream
) integer
1258 :derive-type
#'result-type-first-arg
)
1260 ;;; FIXME: complicated :DESTROYED-CONSTANT-ARGS
1261 (defknown format
((or (member nil t
) stream string
)
1262 (or string function
) &rest t
)
1265 (defknown sb
!format
::args-exhausted
(string integer
) nil
)
1267 (defknown (y-or-n-p yes-or-no-p
) (&optional string
&rest t
) boolean
1270 ;;;; from the "File System Interface" chapter:
1272 ;;; (No pathname functions are FOLDABLE because they all potentially
1273 ;;; depend on *DEFAULT-PATHNAME-DEFAULTS*, e.g. to provide a default
1274 ;;; host when parsing a namestring. They are not FLUSHABLE because
1275 ;;; parsing of a PATHNAME-DESIGNATOR might signal an error.)
1277 (defknown wild-pathname-p
(pathname-designator
1279 (member nil
:host
:device
1285 (defknown pathname-match-p
(pathname-designator pathname-designator
)
1289 (defknown translate-pathname
(pathname-designator
1291 pathname-designator
&key
)
1295 (defknown logical-pathname
(pathname-designator) logical-pathname
())
1296 (defknown translate-logical-pathname
(pathname-designator &key
) pathname
1298 (defknown load-logical-pathname-translations
(string) t
())
1299 (defknown logical-pathname-translations
(logical-host-designator) list
())
1301 (defknown pathname
(pathname-designator) pathname
())
1302 (defknown truename
(pathname-designator) pathname
())
1304 (defknown parse-namestring
1305 (pathname-designator &optional
1306 (or list host string
(member :unspecific
))
1312 (values (or pathname null
) sequence-end
)
1315 (defknown merge-pathnames
1316 (pathname-designator &optional pathname-designator pathname-version
)
1320 (defknown make-pathname
1321 (&key
(:defaults pathname-designator
)
1322 (:host
(or string pathname-host
))
1323 (:device
(or string pathname-device
))
1324 (:directory
(or pathname-directory string
(member :wild
)))
1325 (:name
(or pathname-name string
(member :wild
)))
1326 (:type
(or pathname-type string
(member :wild
)))
1327 (:version pathname-version
) (:case
(member :local
:common
)))
1328 pathname
(unsafely-flushable))
1330 (defknown pathnamep
(t) boolean
(movable flushable
))
1332 (defknown pathname-host
(pathname-designator
1333 &key
(:case
(member :local
:common
)))
1334 pathname-host
(flushable))
1335 (defknown pathname-device
(pathname-designator
1336 &key
(:case
(member :local
:common
)))
1337 pathname-device
(flushable))
1338 (defknown pathname-directory
(pathname-designator
1339 &key
(:case
(member :local
:common
)))
1340 pathname-directory
(flushable))
1341 (defknown pathname-name
(pathname-designator
1342 &key
(:case
(member :local
:common
)))
1343 pathname-name
(flushable))
1344 (defknown pathname-type
(pathname-designator
1345 &key
(:case
(member :local
:common
)))
1346 pathname-type
(flushable))
1347 (defknown pathname-version
(pathname-designator)
1348 pathname-version
(flushable))
1350 (defknown pathname
= (pathname pathname
) boolean
(movable foldable flushable
))
1352 (defknown (namestring file-namestring directory-namestring host-namestring
)
1353 (pathname-designator) (or simple-string null
)
1354 (unsafely-flushable))
1356 (defknown enough-namestring
(pathname-designator &optional pathname-designator
)
1358 (unsafely-flushable))
1360 (defknown user-homedir-pathname
(&optional t
) pathname
(flushable))
1363 (pathname-designator &key
1365 (:direction
(member :input
:output
:io
:probe
))
1366 (:element-type type-specifier
)
1367 (:if-exists
(member :error
:new-version
:rename
1368 :rename-and-delete
:overwrite
1369 :append
:supersede nil
))
1370 (:if-does-not-exist
(member :error
:create nil
))
1371 (:external-format external-format-designator
))
1374 (defknown rename-file
(pathname-designator filename
)
1375 (values pathname pathname pathname
))
1376 (defknown delete-file
(pathname-designator) (eql t
))
1377 (defknown probe-file
(pathname-designator) (or pathname null
) ())
1378 (defknown file-write-date
(pathname-designator) (or unsigned-byte null
)
1380 (defknown file-author
(pathname-designator) (or simple-string null
)
1383 (defknown file-position
(stream &optional
1384 (or unsigned-byte
(member :start
:end
)))
1385 (or unsigned-byte
(member t nil
)))
1386 (defknown file-length
(stream) (or unsigned-byte null
) (unsafely-flushable))
1389 ((or filename stream
)
1393 (:if-does-not-exist t
)
1394 (:external-format external-format-designator
))
1397 (defknown directory
(pathname-designator &key
(:resolve-symlinks t
))
1400 ;;;; from the "Conditions" chapter:
1402 (defknown error
(t &rest t
) nil
)
1403 (defknown cerror
(format-control t
&rest t
) null
)
1404 (defknown invalid-method-error
(t format-control
&rest t
) *) ; FIXME: first arg is METHOD
1405 (defknown method-combination-error
(format-control &rest t
) *)
1406 (defknown signal
(t &rest t
) null
)
1407 (defknown warn
(t &rest t
) null
)
1408 (defknown invoke-debugger
(condition) nil
)
1409 (defknown break
(&optional format-control
&rest t
) null
)
1410 (defknown make-condition
(type-specifier &rest t
) condition
)
1411 (defknown compute-restarts
(&optional
(or condition null
)) list
)
1412 (defknown find-restart
(restart-designator &optional
(or condition null
))
1414 (defknown invoke-restart
(restart-designator &rest t
) *)
1415 (defknown invoke-restart-interactively
(restart-designator) *)
1416 (defknown restart-name
(restart) symbol
)
1417 (defknown (abort muffle-warning
) (&optional
(or condition null
)) nil
)
1418 (defknown continue
(&optional
(or condition null
)) null
)
1419 (defknown (store-value use-value
) (t &optional
(or condition null
))
1422 ;;; and analogous SBCL extension:
1423 (defknown sb
!impl
::%failed-aver
(t) nil
)
1424 (defknown bug
(t &rest t
) nil
) ; never returns
1425 (defknown sb
!int
:simple-reader-error
(stream string
&rest t
) nil
)
1426 (defknown sb
!kernel
:reader-eof-error
(stream string
) nil
)
1429 ;;;; from the "Miscellaneous" Chapter:
1431 (defknown compile
((or symbol cons
) &optional
(or list function null
))
1432 (values (or function symbol cons
) boolean boolean
))
1434 (defknown compile-file
1435 (pathname-designator
1439 (:output-file
(or pathname-designator
1441 ;; FIXME: This last case is a non-ANSI hack.
1445 (:external-format external-format-designator
)
1451 (values (or pathname null
) boolean boolean
))
1453 (defknown (compile-file-pathname)
1454 (pathname-designator &key
(:output-file
(or pathname-designator
1460 ;; FIXME: consider making (OR CALLABLE CONS) something like
1461 ;; EXTENDED-FUNCTION-DESIGNATOR
1462 (defknown disassemble
((or callable cons
) &key
1463 (:stream stream
) (:use-labels t
))
1466 (defknown describe
(t &optional
(or stream
(member t nil
))) (values))
1467 (defknown function-lambda-expression
(function) (values t boolean t
))
1468 (defknown inspect
(t) (values))
1469 (defknown room
(&optional
(member t nil
:default
)) (values))
1470 (defknown ed
(&optional
(or symbol cons filename
))
1472 (defknown dribble
(&optional filename
&key
(:if-exists t
)) (values))
1474 (defknown apropos
(string-designator &optional package-designator t
) (values))
1475 (defknown apropos-list
(string-designator &optional package-designator t
) list
1476 (flushable recursive
))
1478 (defknown get-decoded-time
()
1479 (values (integer 0 59) (integer 0 59) (integer 0 23) (integer 1 31)
1480 (integer 1 12) unsigned-byte
(integer 0 6) boolean
(rational -
24 24))
1483 (defknown get-universal-time
() unsigned-byte
(flushable))
1485 (defknown decode-universal-time
1486 (unsigned-byte &optional
(or null
(rational -
24 24)))
1487 (values (integer 0 59) (integer 0 59) (integer 0 23) (integer 1 31)
1488 (integer 1 12) unsigned-byte
(integer 0 6) boolean
(rational -
24 24))
1491 (defknown encode-universal-time
1492 ((integer 0 59) (integer 0 59) (integer 0 23) (integer 1 31)
1493 (integer 1 12) unsigned-byte
&optional
(or null
(rational -
24 24)))
1497 (defknown (get-internal-run-time get-internal-real-time
)
1498 () internal-time
(flushable))
1500 (defknown sleep
((real 0)) null
(explicit-check))
1502 (defknown call-with-timing
(callable callable
&rest t
) *
1505 ;;; Even though ANSI defines LISP-IMPLEMENTATION-TYPE and
1506 ;;; LISP-IMPLEMENTATION-VERSION to possibly punt and return NIL, we
1507 ;;; know that there's no valid reason for our implementations to ever
1508 ;;; do so, so we can safely guarantee that they'll return strings.
1509 (defknown (lisp-implementation-type lisp-implementation-version
)
1510 () simple-string
(flushable))
1512 ;;; For any of these functions, meaningful information might not be
1513 ;;; available, so -- unlike the related LISP-IMPLEMENTATION-FOO
1514 ;;; functions -- these really can return NIL.
1515 (defknown (machine-type machine-version machine-instance
1516 software-type software-version
1517 short-site-name long-site-name
)
1518 () (or simple-string null
) (flushable))
1520 (defknown identity
(t) t
(movable foldable flushable
)
1521 :derive-type
#'result-type-first-arg
)
1523 (defknown constantly
(t) function
(movable flushable
))
1524 (defknown complement
(function) function
(movable flushable
))
1526 ;;;; miscellaneous extensions
1528 (defknown symbol-global-value
(symbol) t
())
1529 (defknown set-symbol-global-value
(symbol t
) t
()
1530 :derive-type
#'result-type-last-arg
)
1532 (defknown get-bytes-consed
() unsigned-byte
(flushable))
1533 (defknown mask-signed-field
((integer 0 *) integer
) integer
1534 (movable flushable foldable
))
1536 (defknown array-storage-vector
(array) (simple-array * (*))
1539 ;;;; magical compiler frobs
1541 (defknown %rest-values
(t t t
) * (always-translatable))
1542 (defknown %rest-ref
(t t t t
&optional boolean
) * (always-translatable))
1543 (defknown %rest-length
(t t t
) * (always-translatable))
1544 (defknown %rest-null
(t t t t
) * (always-translatable))
1545 (defknown %rest-true
(t t t
) * (always-translatable))
1547 (defknown %unary-truncate
/single-float
(single-float) integer
(movable foldable flushable
))
1548 (defknown %unary-truncate
/double-float
(double-float) integer
(movable foldable flushable
))
1550 ;;; We can't fold this in general because of SATISFIES. There is a
1551 ;;; special optimizer anyway.
1552 (defknown %typep
(t (or type-specifier ctype
)) boolean
1553 (movable flushable explicit-check
))
1554 (defknown %instance-typep
(t (or type-specifier ctype
)) boolean
1555 (movable flushable explicit-check always-translatable
))
1556 ;;; We should never emit a call to %typep-wrapper
1557 (defknown %typep-wrapper
(t t
(or type-specifier ctype
)) t
1558 (movable flushable always-translatable
))
1560 (defknown %cleanup-point
() t
)
1561 (defknown %special-bind
(t t
) t
)
1562 (defknown %special-unbind
(t) t
)
1563 (defknown %listify-rest-args
(t index
) list
(flushable))
1564 (defknown %more-arg-context
(t t
) (values t index
) (flushable))
1565 (defknown %more-arg
(t index
) t
)
1566 #!+stack-grows-downward-not-upward
1567 ;;; FIXME: The second argument here should really be NEGATIVE-INDEX, but doing that
1568 ;;; breaks the build, and I cannot seem to figure out why. --NS 2006-06-29
1569 (defknown %more-kw-arg
(t fixnum
) (values t t
))
1570 (defknown %more-arg-values
(t index index
) * (flushable))
1572 #!-precise-arg-count-error
1573 (defknown %verify-arg-count
(index index
) (values))
1575 (defknown %arg-count-error
(t t
) nil
)
1576 (defknown %unknown-values
() *)
1577 (defknown %catch
(t t
) t
)
1578 (defknown %unwind-protect
(t t
) t
)
1579 (defknown (%catch-breakup %unwind-protect-breakup
) () t
)
1580 (defknown %lexical-exit-breakup
(t) t
)
1581 (defknown %continue-unwind
(t t t
) nil
)
1582 (defknown %throw
(t &rest t
) nil
) ; This is MV-called.
1583 (defknown %nlx-entry
(t) *)
1584 (defknown %%primitive
(t t
&rest t
) *)
1585 (defknown %pop-values
(t) t
)
1586 (defknown %nip-values
(t t
&rest t
) (values))
1587 (defknown %dummy-dx-alloc
(t t
) t
)
1588 (defknown %allocate-closures
(t) *)
1589 (defknown %type-check-error
(t t
) nil
)
1590 (defknown %type-check-error
/c
(t t
) nil
)
1592 ;; FIXME: This function does not return, but due to the implementation
1593 ;; of FILTER-LVAR we cannot write it here.
1594 (defknown %compile-time-type-error
(t t t t t
) *)
1595 (defknown case-failure
(t t t
) nil
)
1597 (defknown %odd-key-args-error
() nil
)
1598 (defknown %unknown-key-arg-error
(t) nil
)
1599 (defknown (%ldb %mask-field
) (bit-index bit-index integer
) unsigned-byte
1600 (movable foldable flushable explicit-check
))
1601 (defknown (%dpb %deposit-field
) (integer bit-index bit-index integer
) integer
1602 (movable foldable flushable explicit-check
))
1603 (defknown %negate
(number) number
(movable foldable flushable explicit-check
))
1604 (defknown %check-bound
(array index fixnum
) index
1605 (movable foldable flushable dx-safe
))
1606 (defknown data-vector-ref
(simple-array index
) t
1607 (foldable unsafely-flushable explicit-check always-translatable
))
1608 (defknown data-vector-ref-with-offset
(simple-array fixnum fixnum
) t
1609 (foldable unsafely-flushable explicit-check always-translatable
))
1610 (defknown data-nil-vector-ref
(simple-array index
) nil
1611 (explicit-check always-translatable
))
1612 (defknown data-vector-set
(array index t
) t
1613 (explicit-check always-translatable
))
1614 (defknown data-vector-set-with-offset
(array fixnum fixnum t
) t
1615 (explicit-check always-translatable
))
1616 (defknown hairy-data-vector-ref
(array index
) t
1617 (foldable explicit-check
))
1618 (defknown hairy-data-vector-set
(array index t
) t
(explicit-check))
1619 (defknown hairy-data-vector-ref
/check-bounds
(array index
) t
1620 (foldable explicit-check
))
1621 (defknown hairy-data-vector-set
/check-bounds
(array index t
)
1624 (defknown %caller-frame
() t
(flushable))
1625 (defknown %caller-pc
() system-area-pointer
(flushable))
1626 (defknown %with-array-data
(array index
(or index null
))
1627 (values (simple-array * (*)) index index index
)
1628 (foldable flushable
))
1629 (defknown %with-array-data
/fp
(array index
(or index null
))
1630 (values (simple-array * (*)) index index index
)
1631 (foldable flushable
))
1632 (defknown %set-symbol-package
(symbol t
) t
())
1633 (defknown %coerce-callable-to-fun
(callable) function
1634 (flushable explicit-check
))
1635 (defknown array-bounding-indices-bad-error
(t t t
) nil
)
1636 (defknown sequence-bounding-indices-bad-error
(t t t
) nil
)
1637 (defknown %find-position
1638 (t sequence t index sequence-end function function
)
1639 (values t
(or index null
))
1641 (defknown (%find-position-if %find-position-if-not
)
1642 (function sequence t index sequence-end function
)
1643 (values t
(or index null
))
1645 (defknown effective-find-position-test
(callable callable
)
1647 (flushable foldable
))
1648 (defknown effective-find-position-key
(callable)
1650 (flushable foldable
))
1652 (defknown (%adjoin %adjoin-eq
)
1655 (explicit-check flushable
))
1657 (defknown (%member %member-eq
1658 %assoc %assoc-eq %rassoc %rassoc-eq
)
1661 (explicit-check foldable flushable
))
1663 (defknown (%adjoin-key %adjoin-key-eq
)
1666 (explicit-check flushable call
))
1668 (defknown (%member-key %member-key-eq
1669 %assoc-key %assoc-key-eq %rassoc-key %rassoc-key-eq
)
1672 (explicit-check foldable flushable call
))
1674 (defknown (%assoc-if %assoc-if-not %rassoc-if %rassoc-if-not
1675 %member-if %member-if-not
)
1678 (explicit-check foldable flushable call
))
1680 (defknown (%assoc-if-key %assoc-if-not-key %rassoc-if-key %rassoc-if-not-key
1681 %member-if-key %member-if-not-key
)
1682 (function list function
)
1684 (explicit-check foldable flushable call
))
1686 (defknown (%adjoin-test %adjoin-test-not
)
1689 (explicit-check flushable call
))
1691 (defknown (%member-test %member-test-not
1692 %assoc-test %assoc-test-not
1693 %rassoc-test %rassoc-test-not
)
1696 (explicit-check foldable flushable call
))
1698 (defknown (%adjoin-key-test %adjoin-key-test-not
)
1699 (t list function function
)
1701 (explicit-check flushable call
))
1703 (defknown (%member-key-test %member-key-test-not
1704 %assoc-key-test %assoc-key-test-not
1705 %rassoc-key-test %rassoc-key-test-not
)
1706 (t list function function
)
1708 (explicit-check foldable flushable call
))
1710 (defknown %check-vector-sequence-bounds
(vector index sequence-end
)
1714 (defknown arg-count-error
(t t t t t t
) nil
())
1718 (defknown (setf aref
) (t array
&rest index
) t
()
1719 :destroyed-constant-args
(nth-constant-args 2)
1720 :derive-type
#'result-type-first-arg
)
1721 (defknown %set-row-major-aref
(array index t
) t
()
1722 :destroyed-constant-args
(nth-constant-args 1))
1723 (defknown (%rplaca %rplacd
) (cons t
) t
()
1724 :destroyed-constant-args
(nth-constant-args 1)
1725 :derive-type
#'result-type-last-arg
)
1726 (defknown %put
(symbol t t
) t
())
1727 (defknown %setelt
(sequence index t
) t
()
1728 :destroyed-constant-args
(nth-constant-args 1)
1729 :derive-type
#'result-type-last-arg
)
1730 (defknown %svset
(simple-vector index t
) t
()
1731 :destroyed-constant-args
(nth-constant-args 1))
1732 (defknown (setf bit
) (bit (array bit
) &rest index
) bit
()
1733 :destroyed-constant-args
(nth-constant-args 2))
1734 (defknown (setf sbit
) (bit (simple-array bit
) &rest index
) bit
()
1735 :destroyed-constant-args
(nth-constant-args 2))
1736 (defknown %charset
(string index character
) character
()
1737 :destroyed-constant-args
(nth-constant-args 1))
1738 (defknown %scharset
(simple-string index character
) character
()
1739 :destroyed-constant-args
(nth-constant-args 1))
1740 (defknown %set-symbol-value
(symbol t
) t
())
1741 (defknown (setf symbol-function
) (function symbol
) function
())
1742 (defknown %set-symbol-plist
(symbol list
) list
()
1743 :derive-type
#'result-type-last-arg
)
1744 (defknown %setnth
(unsigned-byte list t
) t
()
1745 :destroyed-constant-args
(nth-constant-args 2)
1746 :derive-type
#'result-type-last-arg
)
1747 (defknown %set-fill-pointer
(complex-vector index
) index
1749 :destroyed-constant-args
(nth-constant-args 1)
1750 :derive-type
#'result-type-last-arg
)
1752 ;;;; ALIEN and call-out-to-C stuff
1754 ;; Used by WITH-PINNED-OBJECTS
1756 (defknown sb
!vm
::touch-object
(t) (values)
1757 (always-translatable))
1760 (defknown foreign-symbol-dataref-sap
(simple-string)
1762 (movable flushable
))
1764 (defknown foreign-symbol-sap
(simple-string &optional boolean
)
1766 (movable flushable
))
1768 (defknown foreign-symbol-address
(simple-string &optional boolean
)
1769 (values integer boolean
)
1770 (movable flushable
))
1772 ;;;; miscellaneous internal utilities
1774 (defknown %fun-name
(function) t
(flushable))
1775 (defknown (setf %fun-name
) (t function
) t
())
1777 (defknown policy-quality
(policy symbol
) policy-quality
1780 (defknown compiler-error
(t &rest t
) nil
())
1781 (defknown (compiler-warn compiler-style-warn
) (t &rest t
) (values) ())
1782 (defknown (compiler-notify maybe-compiler-notify
) ((or string symbol
) &rest t
)
1785 (defknown style-warn
(t &rest t
) null
())
1787 (defknown coerce-to-condition
((or condition symbol string function
)
1788 list type-specifier symbol
)
1792 (defknown coerce-symbol-to-fun
(symbol)
1796 (defknown sc-number-or-lose
(symbol) sc-number
1799 (defknown set-info-value
(t info-number t
) t
()
1800 :derive-type
#'result-type-last-arg
)
1802 ;;;; memory barriers
1804 (defknown sb
!vm
:%compiler-barrier
() (values) ())
1805 (defknown sb
!vm
:%memory-barrier
() (values) ())
1806 (defknown sb
!vm
:%read-barrier
() (values) ())
1807 (defknown sb
!vm
:%write-barrier
() (values) ())
1808 (defknown sb
!vm
:%data-dependency-barrier
() (values) ())
1811 ;;; Note: This known function does not have an out-of-line definition;
1812 ;;; and if such a definition were needed, it would not need to "call"
1813 ;;; itself inline, but could be a no-op, because the compiler inserts a
1814 ;;; use of the VOP in the function prologue anyway.
1815 (defknown sb
!kernel
::gc-safepoint
() (values) ())
1818 (defknown %compare-and-swap-svref
(simple-vector index t t
) t
1820 (defknown %compare-and-swap-instance-ref
(instance index t t
) t
1822 (defknown %compare-and-swap-symbol-value
(symbol t t
) t
1824 (defknown (%atomic-dec-symbol-global-value %atomic-inc-symbol-global-value
)
1825 (symbol fixnum
) fixnum
)
1826 (defknown (%atomic-dec-car %atomic-inc-car %atomic-dec-cdr %atomic-inc-cdr
)
1827 (cons fixnum
) fixnum
)
1828 (defknown spin-loop-hint
() (values)
1829 (always-translatable))