1 ;;;; the DESCRIBE system
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 ;;; SB-IMPL, not SB!IMPL, since we're built in warm load.
13 (in-package "SB-IMPL")
15 ;;;; Utils, move elsewhere.
17 (defun class-name-or-class (class)
18 (let ((name (class-name class
)))
19 (if (eq class
(find-class name nil
))
23 ;;;; the ANSI interface to function names (and to other stuff too)
24 ;;; Note: this function gets called by the compiler (as of 1.0.17.x,
25 ;;; in MAYBE-INLINE-SYNTACTIC-CLOSURE), and so although ANSI says
26 ;;; we're allowed to return NIL here freely, it seems plausible that
27 ;;; small changes to the circumstances under which this function
28 ;;; returns non-NIL might have subtle consequences on the compiler.
29 ;;; So it might be desirable to have the compiler not rely on this
30 ;;; function, eventually.
31 (defun function-lambda-expression (fun)
32 "Return (VALUES DEFINING-LAMBDA-EXPRESSION CLOSURE-P NAME), where
33 DEFINING-LAMBDA-EXPRESSION is NIL if unknown, or a suitable argument
34 to COMPILE otherwise, CLOSURE-P is non-NIL if the function's definition
35 might have been enclosed in some non-null lexical environment, and
36 NAME is some name (for debugging only) or NIL if there is no name."
37 (declare (type function fun
))
40 (sb-eval:interpreted-function
41 (let ((name (sb-eval:interpreted-function-name fun
))
42 (lambda-list (sb-eval:interpreted-function-lambda-list fun
))
43 (declarations (sb-eval:interpreted-function-declarations fun
))
44 (body (sb-eval:interpreted-function-body fun
)))
45 (values `(lambda ,lambda-list
46 ,@(when declarations
`((declare ,@declarations
)))
50 (sb-interpreter:interpreted-function
51 (sb-interpreter:fun-lambda-expression fun
))
53 (let* ((name (%fun-name fun
))
54 (fun (%simple-fun-self
(%fun-fun fun
)))
55 (code (sb-di::fun-code-header fun
))
56 (info (sb-kernel:%code-debug-info code
))
57 (source (if info
(sb-c::debug-info-source info
))))
58 (cond ((and source
(sb-c::debug-source-form source
)
59 (eq (sb-c::debug-source-function source
) fun
))
60 (values (sb-c::debug-source-form source
) nil name
))
61 ((legal-fun-name-p name
)
62 (let ((exp (fun-name-inline-expansion name
)))
63 (values exp
(not exp
) name
)))
65 (values nil t name
)))))))
67 ;;; Prints X on a single line, limiting output length by *PRINT-RIGHT-MARGIN*
68 ;;; -- good for printing object parts, etc.
69 (defun prin1-to-line (x &key
(columns 1) (reserve 0))
70 (let* ((line (write-to-string x
:escape t
:readably nil
:lines
2 :circle t
))
71 (p (position #\newline line
))
72 (limit (truncate (- *print-right-margin
* reserve
) columns
)))
73 (flet ((trunc (&optional end
)
74 (let ((line-end (- limit
2)))
75 (with-simple-output-to-string (s)
76 (write-string line s
:end
(if end
79 (write-string ".." s
)))))
82 ((> (length line
) limit
)
87 (defun describe (object &optional
(stream-designator *standard-output
*))
88 "Print a description of OBJECT to STREAM-DESIGNATOR."
89 (let ((stream (out-stream-from-designator stream-designator
))
90 (*print-right-margin
* (or *print-right-margin
* 72))
93 (*suppress-print-errors
*
94 (if (subtypep 'serious-condition
*suppress-print-errors
*)
95 *suppress-print-errors
*
97 ;; Until sbcl-0.8.0.x, we did
98 ;; (FRESH-LINE STREAM)
99 ;; (PPRINT-LOGICAL-BLOCK (STREAM NIL)
101 ;; here. However, ANSI's specification of DEFUN DESCRIBE,
102 ;; DESCRIBE exists as an interface primarily to manage argument
103 ;; defaulting (including conversion of arguments T and NIL into
104 ;; stream objects) and to inhibit any return values from
106 ;; doesn't mention either FRESH-LINEing or PPRINT-LOGICAL-BLOCKing,
107 ;; and the example of typical DESCRIBE-OBJECT behavior in ANSI's
108 ;; specification of DESCRIBE-OBJECT will work poorly if we do them
109 ;; here. (The example method for DESCRIBE-OBJECT does its own
110 ;; FRESH-LINEing, which is a physical directive which works poorly
111 ;; inside a pretty-printer logical block.)
112 (handler-bind ((print-not-readable #'print-unreadably
))
113 (describe-object object stream
))
114 ;; We don't TERPRI here either (any more since sbcl-0.8.0.x), because
115 ;; again ANSI's specification of DESCRIBE doesn't mention it and
116 ;; ANSI's example of DESCRIBE-OBJECT does its own final TERPRI.
123 ;;;; * Each interesting class has a primary method of its own.
125 ;;;; * Output looks like
127 ;;;; object-self-string
128 ;;;; [object-type-string]
137 ;;;; * The newline policy that gets the whitespace right is for
138 ;;;; each block to both start and end with a newline.
140 (defgeneric object-self-string
(x))
142 (defmethod object-self-string (x)
145 (defmethod object-self-string ((x symbol
))
146 (let ((*package
* (find-package :keyword
)))
147 (prin1-to-string x
)))
149 (defgeneric object-type-string
(x))
151 (defmethod object-type-string (x)
152 (let ((type (class-name-or-class (class-of x
))))
154 (string-downcase type
)
155 (prin1-to-string type
))))
157 (defmethod object-type-string ((x cons
))
158 (if (listp (cdr x
)) "list" "cons"))
160 (defmethod object-type-string ((x hash-table
))
163 (defmethod object-type-string ((x condition
))
166 (defmethod object-type-string ((x structure-object
))
169 (defmethod object-type-string ((x standard-object
))
172 (defmethod object-type-string ((x function
))
174 (simple-fun "compiled function")
175 (closure "compiled closure")
176 ((or #+sb-fasteval sb-interpreter
:interpreted-function
177 #+sb-eval sb-eval
:interpreted-function
) "interpreted function")
178 (generic-function "generic-function")
179 (t "funcallable-instance")))
181 (defmethod object-type-string ((x stream
))
184 (defmethod object-type-string ((x sb-gray
:fundamental-stream
))
187 (defmethod object-type-string ((x package
))
190 (defmethod object-type-string ((x array
))
191 (cond ((or (stringp x
) (bit-vector-p x
))
192 (format nil
"~@[simple-~*~]~A"
193 (typep x
'simple-array
)
195 (base-string "base-string")
199 (if (simple-vector-p x
)
201 (format nil
"~@[simple ~*~]~@[specialized ~*~]~:[array~;vector~]"
202 (typep x
'simple-array
)
203 (neq t
(array-element-type x
))
206 (defmethod object-type-string ((x character
))
208 (standard-char "standard-char")
209 (base-char "base-char")
210 #+sb-unicode
(t "character"))) ; unreachable if no unicode
212 (defun print-standard-describe-header (x stream
)
213 (format stream
"~&~A~% [~A]~%"
214 (object-self-string x
)
215 (object-type-string x
)))
217 (defgeneric describe-object
(x stream
))
221 (defmethod describe-object ((x t
) s
)
222 (print-standard-describe-header x s
))
224 (defmethod describe-object ((x cons
) s
)
225 (print-standard-describe-header x s
)
226 (describe-function x nil s
))
228 (defmethod describe-object ((x function
) s
)
229 (print-standard-describe-header x s
)
230 (describe-function nil x s
))
232 (defmethod describe-object ((x class
) s
)
233 (print-standard-describe-header x s
)
234 (describe-class nil x s
)
235 (describe-instance x s
))
237 (defmethod describe-object ((x sb-pcl
::slot-object
) s
)
238 (print-standard-describe-header x s
)
239 (describe-instance x s
))
241 (defmethod describe-object ((x character
) s
)
242 (print-standard-describe-header x s
)
243 (format s
"~%Char-code: ~S" (char-code x
))
244 (format s
"~%Char-name: ~A" (char-name x
)))
246 (defmethod describe-object ((x array
) s
)
247 (print-standard-describe-header x s
)
248 (format s
"~%Element-type: ~/sb-impl:print-type-specifier/"
249 (array-element-type x
))
251 (if (array-has-fill-pointer-p x
)
252 (format s
"~%Fill-pointer: ~S~%Size: ~S"
254 (array-total-size x
))
255 (format s
"~%Length: ~S" (length x
)))
256 (format s
"~%Dimensions: ~S" (array-dimensions x
)))
257 (let ((*print-array
* nil
))
258 (unless (typep x
'simple-array
)
259 (format s
"~%Adjustable: ~A" (if (adjustable-array-p x
) "yes" "no"))
260 (multiple-value-bind (to offset
) (array-displacement x
)
261 (if (format s
"~%Displaced-to: ~A~%Displaced-offset: ~S"
264 (format s
"~%Displaced: no"))))
265 (when (and (not (array-displacement x
)) (array-header-p x
))
266 (format s
"~%Storage vector: ~A"
267 (prin1-to-line (array-storage-vector x
))))
270 (defmethod describe-object ((x hash-table
) s
)
271 (print-standard-describe-header x s
)
272 ;; Don't print things which are already apparent from the printed
273 ;; representation -- COUNT, TEST, and WEAKNESS
274 (format s
"~%Occupancy: ~,1F" (float (/ (hash-table-count x
)
275 (hash-table-size x
))))
276 (format s
"~%Rehash-threshold: ~S" (hash-table-rehash-threshold x
))
277 (format s
"~%Rehash-size: ~S" (hash-table-rehash-size x
))
278 (format s
"~%Size: ~S" (hash-table-size x
))
279 (format s
"~%Synchronized: ~A" (if (hash-table-synchronized-p x
) "yes" "no"))
282 (defmethod describe-object ((symbol symbol
) stream
)
283 (print-standard-describe-header symbol stream
)
285 ;; Describe the value cell.
286 (describe-variable symbol stream
)
288 ;; TODO: We could grovel over all packages looking for and
289 ;; reporting other phenomena, e.g. IMPORT and SHADOW, or
290 ;; availability in some package even after (SYMBOL-PACKAGE SYMBOL) has
293 ;; TODO: It might also be nice to describe (find-package symbol)
294 ;; if one exists. Maybe not all the exports, etc, but the package
296 (describe-function symbol nil stream
)
297 (describe-class symbol nil stream
)
300 (describe-type symbol stream
)
302 (awhen (sb-c::policy-quality-name-p symbol
)
303 (pprint-logical-block (stream nil
)
304 (pprint-newline :mandatory stream
)
305 (pprint-indent :block
2 stream
)
306 (format stream
"~A names a~:[ dependent~;n~] optimization policy quality:"
308 (describe-documentation symbol
'optimize stream t
))
311 ;; Print out properties.
312 (let ((plist (symbol-plist symbol
)))
314 (pprint-logical-block (stream nil
)
315 (format stream
"~%Symbol-plist:")
316 (pprint-indent :block
2 stream
)
317 (doplist (key value
) plist
318 (format stream
"~@:_~A -> ~A"
319 (prin1-to-line key
:columns
2 :reserve
5)
320 (prin1-to-line value
:columns
2 :reserve
5))))
323 (defmethod describe-object ((package package
) stream
)
324 (print-standard-describe-header package stream
)
325 (pprint-logical-block (stream nil
)
326 (describe-documentation package t stream
)
327 (flet ((humanize (list)
328 (sort (mapcar (lambda (x)
335 (describe-stuff label list stream
:escape nil
)))
337 (do-external-symbols (ext package
)
340 (let ((implemented (humanize (package-implemented-by-list package
)))
341 (implements (humanize (package-implements-list package
)))
342 (this (list (package-name package
))))
343 (when (package-locked-p package
)
344 (format stream
"~@:_Locked."))
345 (when (set-difference implemented this
:test
#'string
=)
346 (out "Implemented-by-list" implemented
))
347 (when (set-difference implements this
:test
#'string
=)
348 (out "Implements-list" implements
)))
349 (out "Nicknames" (humanize (package-nicknames package
)))
350 (out "Use-list" (humanize (package-use-list package
)))
351 (out "Used-by-list" (humanize (package-used-by-list package
)))
352 (out "Shadows" (humanize (package-shadowing-symbols package
)))
353 (out "Exports" (humanize exports
))
354 (format stream
"~@:_~S internal symbols."
355 (package-internal-symbol-count package
))))
358 ;;;; Helpers to deal with shared functionality
360 (defun describe-deprecation (namespace name stream
)
361 (multiple-value-bind (state since replacements
)
362 (deprecated-thing-p namespace name
)
364 (destructuring-bind (software version
) since
365 (format stream
"~@:_In ~A deprecation since ~@[~A ~]version ~A.~
366 ~@[ ~/sb-impl::print-deprecation-replacements/~]"
367 state software version replacements
)))))
369 (defun describe-class (name class stream
)
370 (binding* ((by-name (not class
))
371 ((name class
) (if class
372 (values (class-name class
) name
)
373 (values name
(find-class name nil
)))))
375 (let ((metaclass-name (class-name (class-of class
))))
376 (pprint-logical-block (stream nil
)
378 (format stream
"~@:_~A names the ~(~A~) ~S:"
379 name metaclass-name class
)
380 (pprint-indent :block
2 stream
))
381 (describe-deprecation 'type name stream
)
382 (describe-documentation class t stream
)
383 (when (sb-mop:class-finalized-p class
)
384 (describe-stuff "Class precedence-list"
385 (mapcar #'class-name-or-class
(sb-mop:class-precedence-list class
))
387 (describe-stuff "Direct superclasses"
388 (mapcar #'class-name-or-class
(sb-mop:class-direct-superclasses class
))
390 (let ((subs (mapcar #'class-name-or-class
(sb-mop:class-direct-subclasses class
))))
392 (describe-stuff "Direct subclasses" subs stream
)
393 (format stream
"~@:_No subclasses.")))
394 (unless (sb-mop:class-finalized-p class
)
395 (format stream
"~@:_Not yet finalized."))
396 (if (eq 'structure-class metaclass-name
)
397 (let* ((dd (find-defstruct-description name
))
398 (slots (dd-slots dd
)))
400 (format stream
"~@:_Slots:~:{~@:_ ~S~
401 ~@:_ Type: ~/sb-impl:print-type-specifier/ ~@[~A~]~
403 (mapcar (lambda (dsd)
407 (unless (eq t
(dsd-raw-type dsd
))
411 (format stream
"~@:_No slots.")))
412 (let ((slots (sb-mop:class-direct-slots class
)))
414 (format stream
"~@:_Direct slots:~:{~@:_ ~S~
415 ~@[~@:_ Type: ~/sb-impl:print-type-specifier/~]~
416 ~@[~@:_ Allocation: ~S~]~
417 ~@[~@:_ Initargs: ~{~S~^, ~}~]~
418 ~@[~@:_ Initform: ~S~]~
419 ~@[~@:_ Readers: ~{~S~^, ~}~]~
420 ~@[~@:_ Writers: ~{~S~^, ~}~]~
421 ~@[~@:_ Documentation:~@:_ ~@<~@;~A~:>~]~}"
422 (mapcar (lambda (slotd)
423 (list (sb-mop:slot-definition-name slotd
)
424 (let ((type (sb-mop:slot-definition-type slotd
)))
425 (unless (eq t type
) type
))
426 (let ((alloc (sb-mop:slot-definition-allocation slotd
)))
427 (unless (eq :instance alloc
) alloc
))
428 (sb-mop:slot-definition-initargs slotd
)
429 (sb-mop:slot-definition-initform slotd
)
430 (sb-mop:slot-definition-readers slotd
)
431 (sb-mop:slot-definition-writers slotd
)
432 ;; FIXME: does this get the prefix right?
433 (quiet-doc slotd t
)))
435 (format stream
"~@:_No direct slots."))))
436 (pprint-indent :block
0 stream
)
437 (pprint-newline :mandatory stream
))))))
439 (defun describe-instance (object stream
)
440 (let* ((class (class-of object
))
441 (slotds (sb-mop:class-slots class
))
442 (max-slot-name-length 0)
445 ;; Figure out a good width for the slot-name column.
446 (flet ((adjust-slot-name-length (name)
447 (setf max-slot-name-length
448 (max max-slot-name-length
(length (symbol-name name
))))))
449 (dolist (slotd slotds
)
450 (adjust-slot-name-length (sb-mop:slot-definition-name slotd
))
451 (push slotd
(getf plist
(sb-mop:slot-definition-allocation slotd
))))
452 (setf max-slot-name-length
(min (+ max-slot-name-length
3) 30)))
454 ;; Now that we know the width, we can print.
455 (flet ((describe-slot (name value
)
456 (format stream
"~% ~A~VT = ~A" name max-slot-name-length
457 (prin1-to-line value
))))
458 (doplist (allocation slots
) plist
459 (format stream
"~%Slots with ~S allocation:" allocation
)
460 (dolist (slotd (nreverse slots
))
462 (sb-mop:slot-definition-name slotd
)
463 (sb-pcl::slot-value-for-printing object
(sb-mop:slot-definition-name slotd
))))))
465 (format stream
"~@:_No slots."))
468 (defun quiet-doc (object type
)
469 (handler-bind ((warning #'muffle-warning
))
470 (documentation object type
)))
472 (defun describe-documentation (object type stream
&optional undoc newline
)
473 (let ((doc (quiet-doc object type
)))
475 (format stream
"~@:_Documentation:~@:_")
476 (pprint-logical-block (stream nil
:per-line-prefix
" ")
479 (format stream
"~@:_(undocumented)")))
481 (pprint-newline :mandatory stream
))))
483 (defun describe-stuff (label list stream
&key
(escape t
))
486 (format stream
"~@:_~A:~@<~;~{ ~S~^,~:_~}~;~:>" label list
)
487 (format stream
"~@:_~A:~@<~;~{ ~A~^,~:_~}~;~:>" label list
))))
489 (defun describe-variable (name stream
)
490 (let* ((kind (info :variable
:kind name
))
492 (:special
"a special variable")
493 (:macro
"a symbol macro")
494 (:constant
"a constant variable")
495 (:global
"a global variable")
496 (:unknown
"an undefined variable")
497 (:alien
"an alien variable"))))
498 (when (and (eq kind
:unknown
) (not (boundp name
)))
499 (return-from describe-variable
))
500 (pprint-logical-block (stream nil
)
501 (format stream
"~@:_~A names ~A:" name wot
)
502 (pprint-indent :block
2 stream
)
503 (describe-deprecation 'variable name stream
)
504 (when (eq (info :variable
:where-from name
) :declared
)
505 (format stream
"~@:_Declared type: ~/sb-impl:print-type/"
506 (info :variable
:type name
)))
507 (when (info :variable
:always-bound name
)
508 (format stream
"~@:_Declared always-bound."))
511 (let ((info (info :variable
:alien-info name
)))
512 (format stream
"~@:_Value: ~S" (eval name
))
513 (format stream
"~@:_Type: ~S"
514 (sb-alien-internals:unparse-alien-type
515 (sb-alien::heap-alien-info-type info
)))
516 (format stream
"~@:_Address: #x~8,'0X"
517 (sap-int (sb-alien::heap-alien-info-sap info
)))))
519 (let ((expansion (info :variable
:macro-expansion name
)))
520 (format stream
"~@:_Expansion: ~S" expansion
)))
522 (format stream
"~:@_Value: ~S" (symbol-value name
)))
523 ((not (eq kind
:unknown
))
524 (format stream
"~:@_Currently unbound.")))
525 (describe-documentation name
'variable stream
)
528 (defun describe-lambda-list (lambda-list stream
)
529 (let ((*print-circle
* nil
)
532 (format stream
"~@:_Lambda-list: ~:A" lambda-list
)))
534 (defun describe-argument-precedence-order (argument-list stream
)
535 (let ((*print-circle
* nil
)
538 (format stream
"~@:_Argument precedence order: ~:A" argument-list
)))
540 (defun describe-function-source (function stream
)
541 (if (compiled-function-p (the function function
))
542 (let* ((code (fun-code-header (%fun-fun function
)))
543 (info (sb-kernel:%code-debug-info code
)))
545 (let ((source (sb-c::debug-info-source info
)))
547 (let ((namestring (sb-c::debug-source-namestring source
)))
548 ;; This used to also report the times the source was created
549 ;; and compiled, but that seems more like noise than useful
550 ;; information -- but FWIW that are to be had as
551 ;; SB-C::DEBUG-SOUCE-CREATED/COMPILED.
553 (format stream
"~@:_Source file: ~A" namestring
))
554 ((sb-di:debug-source-form source
)
555 (format stream
"~@:_Source form:~@:_ ~S"
556 (sb-di:debug-source-form source
)))))))))
560 (sb-eval:interpreted-function
561 (sb-eval:interpreted-function-source-location function
))
563 (sb-interpreter:interpreted-function
564 (sb-interpreter:fun-source-location function
)))))
566 (let ((namestring (sb-c:definition-source-location-namestring source
)))
568 (format stream
"~@:_Source file: ~A" namestring
)))))))
570 (defun describe-function (name function stream
)
571 (let ((name (if function
(%fun-name function
) name
)))
572 (if (not (or function
(and (legal-fun-name-p name
) (fboundp name
))))
573 ;; Not defined, but possibly the type is declared, or we have
574 ;; compiled calls to it.
575 (when (legal-fun-name-p name
)
576 (multiple-value-bind (from sure
) (info :function
:where-from name
)
577 (when (or (eq :declared from
) (and sure
(eq :assumed from
)))
578 (pprint-logical-block (stream nil
)
579 (format stream
"~%~A names an undefined function" name
)
580 (pprint-indent :block
2 stream
)
581 (format stream
"~@:_~:(~A~) type: ~/sb-impl:print-type/"
582 from
(proclaimed-ftype name
))))))
584 (multiple-value-bind (fun what lambda-list derived-type declared-type
585 inline methods argument-precedence-order
)
586 (cond ((and (not function
) (symbolp name
) (special-operator-p name
))
587 ;; The function in the symbol is irrelevant.
588 ;; Use the def-ir1-translator function for source location.
589 (let ((fun (info :function
:ir1-convert name
)))
590 (values fun
"a special operator" (%fun-lambda-list fun
))))
591 ((and (not function
) (symbolp name
) (macro-function name
))
592 (let ((fun (macro-function name
)))
593 (values fun
"a macro" (%fun-lambda-list fun
))))
595 (let* ((fun (or function
(fdefinition name
)))
596 (derived-type (and function
597 (%fun-type function
)))
598 (legal-name-p (legal-fun-name-p name
))
599 (ctype (and legal-name-p
600 (proclaimed-ftype name
)))
601 (type (and ctype
(type-specifier ctype
)))
602 (from (and legal-name-p
603 (info :function
:where-from name
)))
607 (setf declared-type type
))
608 ((and (not derived-type
)
609 (member from
'(:defined-method
:defined
)))
610 (setf derived-type type
)))
612 (setf derived-type
(%fun-type fun
)))
613 (if (typep fun
'standard-generic-function
)
616 (sb-mop:generic-function-lambda-list fun
)
620 (or (sb-mop:generic-function-methods fun
)
622 ;; Argument precedence order
623 ;; information is only interesting
624 ;; for two or more required
626 (let ((order (sb-mop:generic-function-argument-precedence-order
628 (when (>= (length order
) 2)
631 (if (compiled-function-p fun
)
632 "a compiled function"
633 "an interpreted function")
634 (%fun-lambda-list fun
)
638 (info :function
:inlinep name
)
639 (info :function
:inline-expansion-designator
641 (pprint-logical-block (stream nil
)
643 (format stream
"~%~A names ~A:" name what
)
644 (pprint-indent :block
2 stream
))
645 (describe-deprecation 'function name stream
)
646 (describe-lambda-list lambda-list stream
)
647 (when argument-precedence-order
648 (describe-argument-precedence-order argument-precedence-order stream
))
650 (format stream
"~@:_Declared type: ~
651 ~/sb-impl:print-type-specifier/"
653 (when (and derived-type
654 (not (equal declared-type derived-type
)))
655 (format stream
"~@:_Derived type: ~
656 ~/sb-impl:print-type-specifier/"
658 (describe-documentation name
'function stream
)
660 (format stream
"~@:_Inline proclamation: ~
661 ~A (~:[no ~;~]inline expansion available)"
664 (awhen (info :function
:info name
)
665 (awhen (sb-c::decode-ir1-attributes
(sb-c::fun-info-attributes it
))
666 (format stream
"~@:_Known attributes: ~(~{~A~^, ~}~)" it
)))
668 (format stream
"~@:_Method-combination: ~S"
669 (sb-pcl::method-combination-type-name
670 (sb-pcl:generic-function-method-combination fun
)))
671 (cond ((eq :none methods
)
672 (format stream
"~@:_No methods."))
674 (pprint-newline :mandatory stream
)
675 (pprint-logical-block (stream nil
)
676 (format stream
"Methods:")
677 (dolist (method methods
)
678 (pprint-indent :block
2 stream
)
679 (format stream
"~@:_(~A ~{~S ~}~:S)"
681 (method-qualifiers method
)
682 (sb-pcl::unparse-specializers
683 fun
(sb-mop:method-specializers method
)))
684 (pprint-indent :block
4 stream
)
685 (describe-documentation method t stream nil
))))))
686 (describe-function-source fun stream
)
689 (awhen (and (legal-fun-name-p name
) (compiler-macro-function name
))
690 (pprint-logical-block (stream nil
)
691 (format stream
"~@:_~A has a compiler-macro:" name
)
692 (pprint-indent :block
2 stream
)
693 (describe-documentation it t stream
)
694 (describe-function-source it stream
))
696 (when (and (consp name
) (eq 'setf
(car name
)) (not (cddr name
)))
697 (let* ((name2 (second name
))
698 (expander (info :setf
:expander name2
)))
699 (cond ((typep expander
'(and symbol
(not null
)))
700 (pprint-logical-block (stream nil
)
701 (format stream
"~&~A has setf-expansion: ~S"
703 (pprint-indent :block
2 stream
)
704 (describe-documentation name2
'setf stream
))
707 (when (listp expander
)
708 (setq expander
(cdr expander
)))
709 (pprint-logical-block (stream nil
)
710 (format stream
"~&~A has a complex setf-expansion:"
712 (pprint-indent :block
2 stream
)
713 (describe-lambda-list (%fun-lambda-list expander
) stream
)
714 (describe-documentation name2
'setf stream t
)
715 (describe-function-source expander stream
))
718 (describe-function `(setf ,name
) nil stream
))))
720 (defun describe-type (name stream
)
721 (let* ((kind (info :type
:kind name
))
722 (fun (and kind
(info :type
:expander name
)))
723 (fun (if (listp fun
) (car fun
) fun
)))
725 (pprint-newline :mandatory stream
)
726 (pprint-logical-block (stream nil
)
727 (format stream
"~@:_~A names a ~@[primitive~* ~]type-specifier:"
728 name
(eq kind
:primitive
))
729 (pprint-indent :block
2 stream
)
730 (describe-deprecation 'type name stream
)
731 (describe-documentation name
'type stream
(eq t fun
))
732 (when (functionp fun
)
733 (describe-lambda-list (%fun-lambda-list fun
) stream
)
734 (multiple-value-bind (expansion ok
)
735 (handler-case (typexpand-1 name
)
736 (error () (values nil nil
)))
738 (format stream
"~@:_Expansion: ~S" expansion
)))))