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
))
24 (if (typep x
'standard-generic-function
)
25 (sb-pcl:generic-function-name x
)
28 ;;;; the ANSI interface to function names (and to other stuff too)
29 ;;; Note: this function gets called by the compiler (as of 1.0.17.x,
30 ;;; in MAYBE-INLINE-SYNTACTIC-CLOSURE), and so although ANSI says
31 ;;; we're allowed to return NIL here freely, it seems plausible that
32 ;;; small changes to the circumstances under which this function
33 ;;; returns non-NIL might have subtle consequences on the compiler.
34 ;;; So it might be desirable to have the compiler not rely on this
35 ;;; function, eventually.
36 (defun function-lambda-expression (fun)
38 "Return (VALUES DEFINING-LAMBDA-EXPRESSION CLOSURE-P NAME), where
39 DEFINING-LAMBDA-EXPRESSION is NIL if unknown, or a suitable argument
40 to COMPILE otherwise, CLOSURE-P is non-NIL if the function's definition
41 might have been enclosed in some non-null lexical environment, and
42 NAME is some name (for debugging only) or NIL if there is no name."
43 (declare (type function fun
))
46 (sb-eval:interpreted-function
47 (let ((name (sb-eval:interpreted-function-name fun
))
48 (lambda-list (sb-eval:interpreted-function-lambda-list fun
))
49 (declarations (sb-eval:interpreted-function-declarations fun
))
50 (body (sb-eval:interpreted-function-body fun
)))
51 (values `(lambda ,lambda-list
52 ,@(when declarations
`((declare ,@declarations
)))
56 (sb-interpreter:interpreted-function
57 (sb-interpreter:fun-lambda-expression fun
))
59 (let* ((name (fun-name fun
))
60 (fun (%simple-fun-self
(%fun-fun fun
)))
61 (code (sb-di::fun-code-header fun
))
62 (info (sb-kernel:%code-debug-info code
))
63 (source (if info
(sb-c::debug-info-source info
))))
64 (cond ((and source
(sb-c::debug-source-form source
)
65 (eq (sb-c::debug-source-function source
) fun
))
66 (values (sb-c::debug-source-form source
) nil name
))
67 ((legal-fun-name-p name
)
68 (let ((exp (fun-name-inline-expansion name
)))
69 (values exp
(not exp
) name
)))
71 (values nil t name
)))))))
73 ;;; Prints X on a single line, limiting output length by *PRINT-RIGHT-MARGIN*
74 ;;; -- good for printing object parts, etc.
75 (defun prin1-to-line (x &key
(columns 1) (reserve 0))
76 (let* ((line (write-to-string x
:escape t
:readably nil
:lines
2 :circle t
))
77 (p (position #\newline line
))
78 (limit (truncate (- *print-right-margin
* reserve
) columns
)))
79 (flet ((trunc (&optional end
)
80 (let ((line-end (- limit
2)))
81 (with-simple-output-to-string (s)
82 (write-string line s
:end
(if end
85 (write-string ".." s
)))))
88 ((> (length line
) limit
)
93 (defun describe (object &optional
(stream-designator *standard-output
*))
95 "Print a description of OBJECT to STREAM-DESIGNATOR."
96 (let ((stream (out-synonym-of stream-designator
))
97 (*print-right-margin
* (or *print-right-margin
* 72))
99 (*suppress-print-errors
*
100 (if (subtypep 'serious-condition
*suppress-print-errors
*)
101 *suppress-print-errors
*
102 'serious-condition
)))
103 ;; Until sbcl-0.8.0.x, we did
104 ;; (FRESH-LINE STREAM)
105 ;; (PPRINT-LOGICAL-BLOCK (STREAM NIL)
107 ;; here. However, ANSI's specification of DEFUN DESCRIBE,
108 ;; DESCRIBE exists as an interface primarily to manage argument
109 ;; defaulting (including conversion of arguments T and NIL into
110 ;; stream objects) and to inhibit any return values from
112 ;; doesn't mention either FRESH-LINEing or PPRINT-LOGICAL-BLOCKing,
113 ;; and the example of typical DESCRIBE-OBJECT behavior in ANSI's
114 ;; specification of DESCRIBE-OBJECT will work poorly if we do them
115 ;; here. (The example method for DESCRIBE-OBJECT does its own
116 ;; FRESH-LINEing, which is a physical directive which works poorly
117 ;; inside a pretty-printer logical block.)
118 (handler-bind ((print-not-readable #'print-unreadably
))
119 (describe-object object stream
))
120 ;; We don't TERPRI here either (any more since sbcl-0.8.0.x), because
121 ;; again ANSI's specification of DESCRIBE doesn't mention it and
122 ;; ANSI's example of DESCRIBE-OBJECT does its own final TERPRI.
129 ;;;; * Each interesting class has a primary method of its own.
131 ;;;; * Output looks like
133 ;;;; object-self-string
134 ;;;; [object-type-string]
143 ;;;; * The newline policy that gets the whitespace right is for
144 ;;;; each block to both start and end with a newline.
146 (defgeneric object-self-string
(x))
148 (defmethod object-self-string (x)
151 (defmethod object-self-string ((x symbol
))
152 (let ((*package
* (find-package :keyword
)))
153 (prin1-to-string x
)))
155 (defgeneric object-type-string
(x))
157 (defmethod object-type-string (x)
158 (let ((type (class-name-or-class (class-of x
))))
160 (string-downcase type
)
161 (prin1-to-string type
))))
163 (defmethod object-type-string ((x cons
))
164 (if (listp (cdr x
)) "list" "cons"))
166 (defmethod object-type-string ((x hash-table
))
169 (defmethod object-type-string ((x condition
))
172 (defmethod object-type-string ((x structure-object
))
175 (defmethod object-type-string ((x standard-object
))
178 (defmethod object-type-string ((x function
))
180 (simple-fun "compiled function")
181 (closure "compiled closure")
182 ((or #+sb-fasteval sb-interpreter
:interpreted-function
183 #+sb-eval sb-eval
:interpreted-function
) "interpreted function")
184 (generic-function "generic-function")
185 (t "funcallable-instance")))
187 (defmethod object-type-string ((x stream
))
190 (defmethod object-type-string ((x sb-gray
:fundamental-stream
))
193 (defmethod object-type-string ((x package
))
196 (defmethod object-type-string ((x array
))
197 (cond ((or (stringp x
) (bit-vector-p x
))
198 (format nil
"~@[simple-~*~]~A"
199 (typep x
'simple-array
)
201 (base-string "base-string")
205 (if (simple-vector-p x
)
207 (format nil
"~@[simple ~*~]~@[specialized ~*~]~:[array~;vector~]"
208 (typep x
'simple-array
)
209 (neq t
(array-element-type x
))
212 (defmethod object-type-string ((x character
))
214 (standard-char "standard-char")
215 (base-char "base-char")
218 (defun print-standard-describe-header (x stream
)
219 (format stream
"~&~A~% [~A]~%"
220 (object-self-string x
)
221 (object-type-string x
)))
223 (defgeneric describe-object
(x stream
))
227 (defmethod describe-object ((x t
) s
)
228 (print-standard-describe-header x s
))
230 (defmethod describe-object ((x cons
) s
)
231 (print-standard-describe-header x s
)
232 (describe-function x nil s
))
234 (defmethod describe-object ((x function
) s
)
235 (print-standard-describe-header x s
)
236 (describe-function nil x s
))
238 (defmethod describe-object ((x class
) s
)
239 (print-standard-describe-header x s
)
240 (describe-class nil x s
)
241 (describe-instance x s
))
243 (defmethod describe-object ((x sb-pcl
::slot-object
) s
)
244 (print-standard-describe-header x s
)
245 (describe-instance x s
))
247 (defmethod describe-object ((x character
) s
)
248 (print-standard-describe-header x s
)
249 (format s
"~%Char-code: ~S" (char-code x
))
250 (format s
"~%Char-name: ~A" (char-name x
)))
252 (defmethod describe-object ((x array
) s
)
253 (print-standard-describe-header x s
)
254 (format s
"~%Element-type: ~S" (array-element-type x
))
256 (if (array-has-fill-pointer-p x
)
257 (format s
"~%Fill-pointer: ~S~%Size: ~S"
259 (array-total-size x
))
260 (format s
"~%Length: ~S" (length x
)))
261 (format s
"~%Dimensions: ~S" (array-dimensions x
)))
262 (let ((*print-array
* nil
))
263 (unless (typep x
'simple-array
)
264 (format s
"~%Adjustable: ~A" (if (adjustable-array-p x
) "yes" "no"))
265 (multiple-value-bind (to offset
) (array-displacement x
)
266 (if (format s
"~%Displaced-to: ~A~%Displaced-offset: ~S"
269 (format s
"~%Displaced: no"))))
270 (when (and (not (array-displacement x
)) (array-header-p x
))
271 (format s
"~%Storage vector: ~A"
272 (prin1-to-line (array-storage-vector x
))))
275 (defmethod describe-object ((x hash-table
) s
)
276 (print-standard-describe-header x s
)
277 ;; Don't print things which are already apparent from the printed
278 ;; representation -- COUNT, TEST, and WEAKNESS
279 (format s
"~%Occupancy: ~,1F" (float (/ (hash-table-count x
)
280 (hash-table-size x
))))
281 (format s
"~%Rehash-threshold: ~S" (hash-table-rehash-threshold x
))
282 (format s
"~%Rehash-size: ~S" (hash-table-rehash-size x
))
283 (format s
"~%Size: ~S" (hash-table-size x
))
284 (format s
"~%Synchronized: ~A" (if (hash-table-synchronized-p x
) "yes" "no"))
287 (defmethod describe-object ((symbol symbol
) stream
)
288 (print-standard-describe-header symbol stream
)
290 ;; Describe the value cell.
291 (describe-variable symbol stream
)
293 ;; TODO: We could grovel over all packages looking for and
294 ;; reporting other phenomena, e.g. IMPORT and SHADOW, or
295 ;; availability in some package even after (SYMBOL-PACKAGE SYMBOL) has
298 ;; TODO: It might also be nice to describe (find-package symbol)
299 ;; if one exists. Maybe not all the exports, etc, but the package
301 (describe-function symbol nil stream
)
302 (describe-class symbol nil stream
)
305 (describe-type symbol stream
)
307 (awhen (sb-c::policy-quality-name-p symbol
)
308 (pprint-logical-block (stream nil
)
309 (pprint-newline :mandatory stream
)
310 (pprint-indent :block
2 stream
)
311 (format stream
"~A names a~:[ dependent~;n~] optimization policy quality:"
313 (describe-documentation symbol
'optimize stream t
))
316 ;; Print out properties.
317 (let ((plist (symbol-plist symbol
)))
319 (pprint-logical-block (stream nil
)
320 (format stream
"~%Symbol-plist:")
321 (pprint-indent :block
2 stream
)
322 (sb-pcl::doplist
(key value
) plist
323 (format stream
"~@:_~A -> ~A"
324 (prin1-to-line key
:columns
2 :reserve
5)
325 (prin1-to-line value
:columns
2 :reserve
5))))
328 (defmethod describe-object ((package package
) stream
)
329 (print-standard-describe-header package stream
)
330 (pprint-logical-block (stream nil
)
331 (describe-documentation package t stream
)
332 (flet ((humanize (list)
333 (sort (mapcar (lambda (x)
340 (describe-stuff label list stream
:escape nil
)))
342 (do-external-symbols (ext package
)
345 (let ((implemented (humanize (package-implemented-by-list package
)))
346 (implements (humanize (package-implements-list package
)))
347 (this (list (package-name package
))))
348 (when (package-locked-p package
)
349 (format stream
"~@:_Locked."))
350 (when (set-difference implemented this
:test
#'string
=)
351 (out "Implemented-by-list" implemented
))
352 (when (set-difference implements this
:test
#'string
=)
353 (out "Implements-list" implements
)))
354 (out "Nicknames" (humanize (package-nicknames package
)))
355 (out "Use-list" (humanize (package-use-list package
)))
356 (out "Used-by-list" (humanize (package-used-by-list package
)))
357 (out "Shadows" (humanize (package-shadowing-symbols package
)))
358 (out "Exports" (humanize exports
))
359 (format stream
"~@:_~S internal symbols."
360 (package-internal-symbol-count package
))))
363 ;;;; Helpers to deal with shared functionality
365 (defun describe-deprecation (namespace name stream
)
366 (multiple-value-bind (state since replacements
)
367 (deprecated-thing-p namespace name
)
369 (destructuring-bind (software version
) since
370 (format stream
"~@:_In ~A deprecation since ~@[~A ~]version ~A.~
371 ~@[ ~/sb-impl::print-deprecation-replacements/~]"
372 state software version replacements
)))))
374 (defun describe-class (name class stream
)
375 (binding* ((by-name (not class
))
376 ((name class
) (if class
377 (values (class-name class
) name
)
378 (values name
(find-class name nil
)))))
380 (let ((metaclass-name (class-name (class-of class
))))
381 (pprint-logical-block (stream nil
)
383 (format stream
"~@:_~A names the ~(~A~) ~S:"
384 name metaclass-name class
)
385 (pprint-indent :block
2 stream
))
386 (describe-deprecation 'type name stream
)
387 (describe-documentation class t stream
)
388 (when (sb-mop:class-finalized-p class
)
389 (describe-stuff "Class precedence-list"
390 (mapcar #'class-name-or-class
(sb-mop:class-precedence-list class
))
392 (describe-stuff "Direct superclasses"
393 (mapcar #'class-name-or-class
(sb-mop:class-direct-superclasses class
))
395 (let ((subs (mapcar #'class-name-or-class
(sb-mop:class-direct-subclasses class
))))
397 (describe-stuff "Direct subclasses" subs stream
)
398 (format stream
"~@:_No subclasses.")))
399 (unless (sb-mop:class-finalized-p class
)
400 (format stream
"~@:_Not yet finalized."))
401 (if (eq 'structure-class metaclass-name
)
402 (let* ((dd (find-defstruct-description name
))
403 (slots (dd-slots dd
)))
405 (format stream
"~@:_Slots:~:{~@:_ ~S~
406 ~@:_ Type: ~A ~@[~A~]~
408 (mapcar (lambda (dsd)
412 (unless (eq t
(dsd-raw-type dsd
))
416 (format stream
"~@:_No slots.")))
417 (let ((slots (sb-mop:class-direct-slots class
)))
419 (format stream
"~@:_Direct slots:~:{~@:_ ~S~
421 ~@[~@:_ Allocation: ~S~]~
422 ~@[~@:_ Initargs: ~{~S~^, ~}~]~
423 ~@[~@:_ Initform: ~S~]~
424 ~@[~@:_ Readers: ~{~S~^, ~}~]~
425 ~@[~@:_ Writers: ~{~S~^, ~}~]~
426 ~@[~@:_ Documentation:~@:_ ~@<~@;~A~:>~]~}"
427 (mapcar (lambda (slotd)
428 (list (sb-mop:slot-definition-name slotd
)
429 (let ((type (sb-mop:slot-definition-type slotd
)))
430 (unless (eq t type
) type
))
431 (let ((alloc (sb-mop:slot-definition-allocation slotd
)))
432 (unless (eq :instance alloc
) alloc
))
433 (sb-mop:slot-definition-initargs slotd
)
434 (sb-mop:slot-definition-initform slotd
)
435 (sb-mop:slot-definition-readers slotd
)
436 (sb-mop:slot-definition-writers slotd
)
437 ;; FIXME: does this get the prefix right?
438 (quiet-doc slotd t
)))
440 (format stream
"~@:_No direct slots."))))
441 (pprint-indent :block
0 stream
)
442 (pprint-newline :mandatory stream
))))))
444 (defun describe-instance (object stream
)
445 (let* ((class (class-of object
))
446 (slotds (sb-mop:class-slots class
))
447 (max-slot-name-length 0)
450 ;; Figure out a good width for the slot-name column.
451 (flet ((adjust-slot-name-length (name)
452 (setf max-slot-name-length
453 (max max-slot-name-length
(length (symbol-name name
))))))
454 (dolist (slotd slotds
)
455 (adjust-slot-name-length (sb-mop:slot-definition-name slotd
))
456 (push slotd
(getf plist
(sb-mop:slot-definition-allocation slotd
))))
457 (setf max-slot-name-length
(min (+ max-slot-name-length
3) 30)))
459 ;; Now that we know the width, we can print.
460 (flet ((describe-slot (name value
)
461 (format stream
"~% ~A~VT = ~A" name max-slot-name-length
462 (prin1-to-line value
))))
463 (sb-pcl::doplist
(allocation slots
) plist
464 (format stream
"~%Slots with ~S allocation:" allocation
)
465 (dolist (slotd (nreverse slots
))
467 (sb-mop:slot-definition-name slotd
)
468 (sb-pcl::slot-value-or-default object
(sb-mop:slot-definition-name slotd
))))))
470 (format stream
"~@:_No slots."))
473 (defun quiet-doc (object type
)
474 (handler-bind ((warning #'muffle-warning
))
475 (documentation object type
)))
477 (defun describe-documentation (object type stream
&optional undoc newline
)
478 (let ((doc (quiet-doc object type
)))
480 (format stream
"~@:_Documentation:~@:_")
481 (pprint-logical-block (stream nil
:per-line-prefix
" ")
484 (format stream
"~@:_(undocumented)")))
486 (pprint-newline :mandatory stream
))))
488 (defun describe-stuff (label list stream
&key
(escape t
))
491 (format stream
"~@:_~A:~@<~;~{ ~S~^,~:_~}~;~:>" label list
)
492 (format stream
"~@:_~A:~@<~;~{ ~A~^,~:_~}~;~:>" label list
))))
494 (defun describe-variable (name stream
)
495 (let* ((kind (info :variable
:kind name
))
497 (:special
"a special variable")
498 (:macro
"a symbol macro")
499 (:constant
"a constant variable")
500 (:global
"a global variable")
501 (:unknown
"an undefined variable")
502 (:alien
"an alien variable"))))
503 (when (and (eq kind
:unknown
) (not (boundp name
)))
504 (return-from describe-variable
))
505 (pprint-logical-block (stream nil
)
506 (format stream
"~@:_~A names ~A:" name wot
)
507 (pprint-indent :block
2 stream
)
508 (describe-deprecation 'variable name stream
)
509 (when (eq (info :variable
:where-from name
) :declared
)
510 (format stream
"~@:_Declared type: ~S"
511 (type-specifier (info :variable
:type name
))))
512 (when (info :variable
:always-bound name
)
513 (format stream
"~@:_Declared always-bound."))
516 (let ((info (info :variable
:alien-info name
)))
517 (format stream
"~@:_Value: ~S" (eval name
))
518 (format stream
"~@:_Type: ~S"
519 (sb-alien-internals:unparse-alien-type
520 (sb-alien::heap-alien-info-type info
)))
521 (format stream
"~@:_Address: #x~8,'0X"
522 (sap-int (sb-alien::heap-alien-info-sap info
)))))
524 (let ((expansion (info :variable
:macro-expansion name
)))
525 (format stream
"~@:_Expansion: ~S" expansion
)))
527 (format stream
"~:@_Value: ~S" (symbol-value name
)))
528 ((not (eq kind
:unknown
))
529 (format stream
"~:@_Currently unbound.")))
530 (describe-documentation name
'variable stream
)
533 (defun describe-lambda-list (lambda-list stream
)
534 (let ((*print-circle
* nil
)
537 (format stream
"~@:_Lambda-list: ~:A" lambda-list
)))
539 (defun describe-function-source (function stream
)
540 (if (compiled-function-p (the function function
))
541 (let* ((code (fun-code-header (%fun-fun function
)))
542 (info (sb-kernel:%code-debug-info code
)))
544 (let ((source (sb-c::debug-info-source info
)))
546 (let ((namestring (sb-c::debug-source-namestring source
)))
547 ;; This used to also report the times the source was created
548 ;; and compiled, but that seems more like noise than useful
549 ;; information -- but FWIW that are to be had as
550 ;; SB-C::DEBUG-SOUCE-CREATED/COMPILED.
552 (format stream
"~@:_Source file: ~A" namestring
))
553 ((sb-di:debug-source-form source
)
554 (format stream
"~@:_Source form:~@:_ ~S"
555 (sb-di:debug-source-form source
)))))))))
559 (sb-eval:interpreted-function
560 (sb-eval:interpreted-function-source-location function
))
562 (sb-interpreter:interpreted-function
563 (sb-interpreter:fun-source-location function
)))))
565 (let ((namestring (sb-c:definition-source-location-namestring source
)))
567 (format stream
"~@:_Source file: ~A" namestring
)))))))
569 (defun describe-function (name function stream
)
570 (let ((name (if function
(fun-name function
) name
)))
571 (if (not (or function
(and (legal-fun-name-p name
) (fboundp name
))))
572 ;; Not defined, but possibly the type is declared, or we have
573 ;; compiled calls to it.
574 (when (legal-fun-name-p name
)
575 (multiple-value-bind (from sure
) (info :function
:where-from name
)
576 (when (or (eq :declared from
) (and sure
(eq :assumed from
)))
577 (pprint-logical-block (stream nil
)
578 (format stream
"~%~A names an undefined function" name
)
579 (pprint-indent :block
2 stream
)
580 (format stream
"~@:_~:(~A~) type: ~S"
582 (type-specifier (proclaimed-ftype name
)))))))
584 (multiple-value-bind (fun what lambda-list derived-type declared-type
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
)
623 (if (compiled-function-p fun
)
624 "a compiled function"
625 "an interpreted function")
626 (%fun-lambda-list fun
)
630 (info :function
:inlinep name
)
631 (info :function
:inline-expansion-designator
633 (pprint-logical-block (stream nil
)
635 (format stream
"~%~A names ~A:" name what
)
636 (pprint-indent :block
2 stream
))
637 (describe-deprecation 'function name stream
)
638 (describe-lambda-list lambda-list stream
)
640 (format stream
"~@:_Declared type: ~S" declared-type
))
641 (when (and derived-type
642 (not (equal declared-type derived-type
)))
643 (format stream
"~@:_Derived type: ~S" derived-type
))
644 (describe-documentation name
'function stream
)
646 (format stream
"~@:_Inline proclamation: ~
647 ~A (~:[no ~;~]inline expansion available)"
650 (awhen (info :function
:info name
)
651 (awhen (sb-c::decode-ir1-attributes
(sb-c::fun-info-attributes it
))
652 (format stream
"~@:_Known attributes: ~(~{~A~^, ~}~)" it
)))
654 (format stream
"~@:_Method-combination: ~S"
655 (sb-pcl::method-combination-type-name
656 (sb-pcl:generic-function-method-combination fun
)))
657 (cond ((eq :none methods
)
658 (format stream
"~@:_No methods."))
660 (pprint-newline :mandatory stream
)
661 (pprint-logical-block (stream nil
)
662 (format stream
"Methods:")
663 (dolist (method methods
)
664 (pprint-indent :block
2 stream
)
665 (format stream
"~@:_(~A ~{~S ~}~:S)"
667 (method-qualifiers method
)
668 (sb-pcl::unparse-specializers
669 fun
(sb-mop:method-specializers method
)))
670 (pprint-indent :block
4 stream
)
671 (describe-documentation method t stream nil
))))))
672 (describe-function-source fun stream
)
675 (awhen (and (legal-fun-name-p name
) (compiler-macro-function name
))
676 (pprint-logical-block (stream nil
)
677 (format stream
"~@:_~A has a compiler-macro:" name
)
678 (pprint-indent :block
2 stream
)
679 (describe-documentation it t stream
)
680 (describe-function-source it stream
))
682 (when (and (consp name
) (eq 'setf
(car name
)) (not (cddr name
)))
683 (let* ((name2 (second name
))
684 (inverse (info :setf
:inverse name2
))
685 (expander (info :setf
:expander name2
)))
687 (pprint-logical-block (stream nil
)
688 (format stream
"~&~A has setf-expansion: ~S"
690 (pprint-indent :block
2 stream
)
691 (describe-documentation name2
'setf stream
))
694 (when (listp expander
)
695 (setq expander
(cdr expander
)))
696 (pprint-logical-block (stream nil
)
697 (format stream
"~&~A has a complex setf-expansion:"
699 (pprint-indent :block
2 stream
)
700 (describe-lambda-list (%fun-lambda-list expander
) stream
)
701 (describe-documentation name2
'setf stream t
)
702 (describe-function-source expander stream
))
705 (describe-function `(setf ,name
) nil stream
))))
707 (defun describe-type (name stream
)
708 (let* ((kind (info :type
:kind name
))
709 (fun (and kind
(info :type
:expander name
)))
710 (fun (if (listp fun
) (car fun
) fun
)))
712 (pprint-newline :mandatory stream
)
713 (pprint-logical-block (stream nil
)
714 (format stream
"~@:_~A names a ~@[primitive~* ~]type-specifier:"
715 name
(eq kind
:primitive
))
716 (pprint-indent :block
2 stream
)
717 (describe-deprecation 'type name stream
)
718 (describe-documentation name
'type stream
(eq t fun
))
719 (when (functionp fun
)
720 (describe-lambda-list (%fun-lambda-list fun
) stream
)
721 (multiple-value-bind (expansion ok
)
722 (handler-case (typexpand-1 name
)
723 (error () (values nil nil
)))
725 (format stream
"~@:_Expansion: ~S" expansion
)))))