#+sb-doc
"Print a description of OBJECT to STREAM-DESIGNATOR."
(let ((stream (out-synonym-of stream-designator))
- (*print-right-margin* (or *print-right-margin* 72)))
+ (*print-right-margin* (or *print-right-margin* 72))
+ (*print-circle* t)
+ (*suppress-print-errors*
+ (if (subtypep 'serious-condition *suppress-print-errors*)
+ *suppress-print-errors*
+ 'serious-condition)))
;; Until sbcl-0.8.0.x, we did
;; (FRESH-LINE STREAM)
;; (PPRINT-LOGICAL-BLOCK (STREAM NIL)
;; here. (The example method for DESCRIBE-OBJECT does its own
;; FRESH-LINEing, which is a physical directive which works poorly
;; inside a pretty-printer logical block.)
- (describe-object object stream)
+ (handler-bind ((print-not-readable #'print-unreadably))
+ (describe-object object stream))
;; We don't TERPRI here either (any more since sbcl-0.8.0.x), because
;; again ANSI's specification of DESCRIBE doesn't mention it and
;; ANSI's example of DESCRIBE-OBJECT does its own final TERPRI.
(base-char "base-char")
(t "character")))
-(defgeneric describe-object (x stream))
-
-(defvar *in-describe* nil)
+(defun print-standard-describe-header (x stream)
+ (format stream "~&~A~% [~A]~%"
+ (object-self-string x)
+ (object-type-string x)))
-(defmethod describe-object :around (x s)
- (cond (*in-describe*
- (call-next-method))
- (t
- (format s "~&~A~% [~A]~%"
- (object-self-string x)
- (object-type-string x))
- (pprint-logical-block (s nil)
- (call-next-method x s)))))
+(defgeneric describe-object (x stream))
;;; Catch-all.
+
(defmethod describe-object ((x t) s)
- (values))
+ (print-standard-describe-header x s))
(defmethod describe-object ((x cons) s)
+ (print-standard-describe-header x s)
(describe-function x nil s))
(defmethod describe-object ((x function) s)
+ (print-standard-describe-header x s)
(describe-function nil x s))
(defmethod describe-object ((x class) s)
+ (print-standard-describe-header x s)
(describe-class nil x s)
(describe-instance x s))
(defmethod describe-object ((x sb-pcl::slot-object) s)
+ (print-standard-describe-header x s)
(describe-instance x s))
(defmethod describe-object ((x character) s)
+ (print-standard-describe-header x s)
(format s "~%:_Char-code: ~S" (char-code x))
(format s "~%:_Char-name: ~A~%_" (char-name x)))
(defmethod describe-object ((x array) s)
+ (print-standard-describe-header x s)
(format s "~%Element-type: ~S" (array-element-type x))
(if (vectorp x)
(if (array-has-fill-pointer-p x)
(terpri s)))
(defmethod describe-object ((x hash-table) s)
- ;; Don't print things which are already apparent from the printed representation
- ;; -- COUNT, TEST, and WEAKNESS
- (format s "~%Occupancy: ~,1F" (float (/ (hash-table-count x) (hash-table-size x))))
+ (print-standard-describe-header x s)
+ ;; Don't print things which are already apparent from the printed
+ ;; representation -- COUNT, TEST, and WEAKNESS
+ (format s "~%Occupancy: ~,1F" (float (/ (hash-table-count x)
+ (hash-table-size x))))
(format s "~%Rehash-threshold: ~S" (hash-table-rehash-threshold x))
(format s "~%Rehash-size: ~S" (hash-table-rehash-size x))
(format s "~%Size: ~S" (hash-table-size x))
(terpri s))
(defmethod describe-object ((symbol symbol) stream)
+ (print-standard-describe-header symbol stream)
;; Describe the value cell.
(let* ((kind (info :variable :kind symbol))
(wot (ecase kind
(:alien "an alien variable"))))
(when (or (not (eq :unknown kind)) (boundp symbol))
(pprint-logical-block (stream nil)
- (format stream "~%~A names ~A:" symbol wot)
+ (format stream "~@:_~A names ~A:" symbol wot)
(pprint-indent :block 2 stream)
(when (eq (info :variable :where-from symbol) :declared)
(format stream "~@:_Declared type: ~S"
(type-specifier (info :variable :type symbol))))
+ (when (info :variable :always-bound symbol)
+ (format stream "~@:_Declared always-bound."))
(cond
((eq kind :alien)
(let ((info (info :variable :alien-info symbol)))
(when fun
(pprint-newline :mandatory stream)
(pprint-logical-block (stream nil)
- (pprint-indent :block 2 stream)
- (format stream "~A names a ~@[primitive~* ~]type-specifier:"
+ (format stream "~@:_~A names a ~@[primitive~* ~]type-specifier:"
symbol
(eq kind :primitive))
+ (pprint-indent :block 2 stream)
(describe-documentation symbol 'type stream (eq t fun))
(unless (eq t fun)
(describe-lambda-list (if (eq :primitive kind)
(format stream "~@:_Expansion: ~S" (funcall fun (list symbol))))))
(terpri stream)))
+ (when (or (member symbol sb-c::*policy-qualities*)
+ (assoc symbol sb-c::*policy-dependent-qualities*))
+ (pprint-logical-block (stream nil)
+ (pprint-newline :mandatory stream)
+ (pprint-indent :block 2 stream)
+ (format stream "~A names a~:[ dependent~;n~] optimization policy quality:"
+ symbol
+ (member symbol sb-c::*policy-qualities*))
+ (describe-documentation symbol 'optimize stream t))
+ (terpri stream))
+
;; Print out properties.
(let ((plist (symbol-plist symbol)))
(when plist
(terpri stream))))
(defmethod describe-object ((package package) stream)
- (describe-documentation package t stream)
- (flet ((humanize (list)
- (sort (mapcar (lambda (x)
- (if (packagep x)
- (package-name x)
- x))
- list)
- #'string<))
- (out (label list)
- (describe-stuff label list stream :escape nil)))
- (let ((implemented (humanize (package-implemented-by-list package)))
- (implements (humanize (package-implements-list package)))
- (nicks (humanize (package-nicknames package)))
- (uses (humanize (package-use-list package)))
- (used (humanize (package-used-by-list package)))
- (shadows (humanize (package-shadowing-symbols package)))
- (this (list (package-name package)))
- (exports nil))
- (do-external-symbols (ext package)
- (push ext exports))
- (setf exports (humanize exports))
- (when (package-locked-p package)
- (format stream "~@:_Locked."))
- (when (set-difference implemented this :test #'string=)
- (out "Implemented-by-list" implemented))
- (when (set-difference implements this :test #'string=)
- (out "Implements-list" implements))
- (out "Nicknames" nicks)
- (out "Use-list" uses)
- (out "Used-by-list" used)
- (out "Shadows" shadows)
- (out "Exports" exports)
- (format stream "~@:_~S internal symbols."
- (package-internal-symbol-count package))))
- (terpri stream))
+ (print-standard-describe-header package stream)
+ (pprint-logical-block (stream nil)
+ (describe-documentation package t stream)
+ (flet ((humanize (list)
+ (sort (mapcar (lambda (x)
+ (if (packagep x)
+ (package-name x)
+ x))
+ list)
+ #'string<))
+ (out (label list)
+ (describe-stuff label list stream :escape nil)))
+ (let ((implemented (humanize (package-implemented-by-list package)))
+ (implements (humanize (package-implements-list package)))
+ (nicks (humanize (package-nicknames package)))
+ (uses (humanize (package-use-list package)))
+ (used (humanize (package-used-by-list package)))
+ (shadows (humanize (package-shadowing-symbols package)))
+ (this (list (package-name package)))
+ (exports nil))
+ (do-external-symbols (ext package)
+ (push ext exports))
+ (setf exports (humanize exports))
+ (when (package-locked-p package)
+ (format stream "~@:_Locked."))
+ (when (set-difference implemented this :test #'string=)
+ (out "Implemented-by-list" implemented))
+ (when (set-difference implements this :test #'string=)
+ (out "Implements-list" implements))
+ (out "Nicknames" nicks)
+ (out "Use-list" uses)
+ (out "Used-by-list" used)
+ (out "Shadows" shadows)
+ (out "Exports" exports)
+ (format stream "~@:_~S internal symbols."
+ (package-internal-symbol-count package))))
+ (terpri stream)))
\f
;;;; Helpers to deal with shared functionality
(let ((metaclass-name (class-name (class-of class))))
(pprint-logical-block (stream nil)
(when by-name
- (format stream "~%~A names the ~(~A~) ~S:"
+ (format stream "~@:_~A names the ~(~A~) ~S:"
name
metaclass-name
class)
(quiet-doc slotd t)))
slots))
(format stream "~@:_No direct slots."))))
+ (pprint-indent :block 0 stream)
(pprint-newline :mandatory stream))))))
(defun describe-instance (object stream)
(format stream "~@:_Source file: ~A" namestring))
((sb-di:debug-source-form source)
(format stream "~@:_Source form:~@:_ ~S"
- (sb-di:debug-source-form source)))
- (t (bug "Don't know how to use a DEBUG-SOURCE without ~
- a namestring or a form."))))))))
+ (sb-di:debug-source-form source)))))))))
#+sb-eval
(let ((source (sb-eval:interpreted-function-source-location function)))
(when source
(format stream "~&~A has a complex setf-expansion:"
name)
(pprint-indent :block 2 stream)
- (describe-documentation name2 'setf stream t))
+ (describe-lambda-list (%fun-lambda-list expander) stream)
+ (describe-documentation name2 'setf stream t)
+ (describe-function-source expander stream))
(terpri stream)))))
(when (symbolp name)
(describe-function `(setf ,name) nil stream))))