Update of /cvsroot/sbcl/sbcl/src/code
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv10797/src/code
Modified Files:
primordial-extensions.lisp
Log Message:
1.0.7.18: automagic debugging-friendly gensyms
* New function: SB-INT:BLOCK-GENSYM, which appends the innermost
enclosing non-NIL block name to the given stem. The default
environment used is the current *LEXENV* if one exists.
* Use it instead of GENSYM in MAKE-GENSYM-LIST and WITH-UNIQUE-NAMES.
Index: primordial-extensions.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/primordial-extensions.lisp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- primordial-extensions.lisp 14 Jul 2005 16:30:37 -0000 1.34
+++ primordial-extensions.lisp 13 Jul 2007 18:57:24 -0000 1.35
@@ -124,6 +124,16 @@
;;;; GENSYM tricks
+;;; GENSYM variant for easier debugging and better backtraces: append
+;;; the closest enclosing non-nil block name to the provided stem.
+(defun block-gensym (&optional (name "G") (env (when (boundp 'sb!c::*lexenv*)
+ (symbol-value 'sb!c::*lexenv*))))
+ (let ((block-name (when env
+ (car (find-if #'car (sb!c::lexenv-blocks env))))))
+ (if block-name
+ (gensym (format nil "~A[~S]" name block-name))
+ (gensym name))))
+
;;; Automate an idiom often found in macros:
;;; (LET ((FOO (GENSYM "FOO"))
;;; (MAX-INDEX (GENSYM "MAX-INDEX-")))
@@ -139,7 +149,7 @@
(stem (if (every #'alpha-char-p symbol-name)
symbol-name
(concatenate 'string symbol-name "-"))))
- `(,symbol (gensym ,stem))))
+ `(,symbol (block-gensym ,stem))))
symbols)
,@body))
@@ -147,7 +157,7 @@
;;; macros and other code-manipulating code.)
(declaim (ftype (function (index) list) make-gensym-list))
(defun make-gensym-list (n)
- (loop repeat n collect (gensym)))
+ (loop repeat n collect (block-gensym)))
;;;; miscellany
|