-;;; shorthand for creating debug names from source names or other
-;;; stems, e.g.
-;;; (DEBUG-NAMIFY "FLET ~S" SOURCE-NAME)
-;;; (DEBUG-NAMIFY "top level form ~S" FORM)
-;;;
-;;; FIXME: This function seems to have a lot in common with
-;;; STRINGIFY-FORM, and perhaps there's some way to merge the two
-;;; functions.
-(declaim (ftype (sfunction (string &rest t) string) debug-namify))
-(defun debug-namify (format-string &rest format-arguments)
- (with-standard-io-syntax
- (let ((*print-readably* nil)
- (*package* *cl-package*)
- (*print-length* 3)
- (*print-level* 2))
- (apply #'format nil format-string format-arguments))))
+(defvar *debug-name-level* 6)
+
+(defun debug-name (type thing)
+ (labels ((walk (x level)
+ (if (> *debug-name-level* (incf level))
+ (typecase x
+ (cons
+ (cons (walk (car x) level) (walk (cdr x) level)))
+ ((or symbol number string)
+ x)
+ (t
+ (list 'of-type (type-of x))))
+ "#<...>")))
+ ;; FIXME: It might be nice to put markers in the tree instead of
+ ;; this #<...> business, so that they would evantually be printed
+ ;; without the quotes.
+ (let ((name (list type (walk thing 0))))
+ (when (legal-fun-name-p name)
+ (bug "~S is a legal function name, and cannot be used as a ~
+ debug name." name))
+ name)))