From: ········@gmail.com
Subject: Re: uninterned symbols
Date:
Message-ID: <1145227004.862733.201070@z34g2000cwc.googlegroups.com>
> (let ((#1=#:g1 1))
> #1#)
I find this useful when refactoring generated code in the repl..
(defun sync-gensyms (tree)
(let ((gensym-pairs nil))
(labels ((sync (g)
(let ((n (symbol-name g)))
(if* (cdr (assoc n gensym-pairs
:test #'string=))
thenret
else (push (cons n (gensym)) gensym-pairs)
(cdr (assoc n gensym-pairs
:test #'string=)))))
(rfn (tr)
(when tr
(if* (listp tr)
then (cons (rfn (car tr))
(rfn (cdr tr)))
elseif (and (symbolp tr)
(null (symbol-package tr)))
then (sync tr)
else tr))))
(rfn tree))))
Nick
From: ········@gmail.com
Subject: Re: uninterned symbols
Date:
Message-ID: <1145227138.338174.35940@t31g2000cwb.googlegroups.com>
>[code with if*]
oops, see http://www.franz.com/~jkf/coding_standards.html for if*
Nick
From: Takehiko Abe
Subject: Re: uninterned symbols
Date:
Message-ID: <keke-1704061256510001@192.168.1.2>
> (defun sync-gensyms (tree)
> (let ((gensym-pairs nil))
> (labels ((sync (g)
> (let ((n (symbol-name g)))
> (if* (cdr (assoc n gensym-pairs
> :test #'string=))
> thenret
> else (push (cons n (gensym)) gensym-pairs)
> (cdr (assoc n gensym-pairs
> :test #'string=)))))
> (rfn (tr)
> (when tr
> (if* (listp tr)
> then (cons (rfn (car tr))
> (rfn (cdr tr)))
> elseif (and (symbolp tr)
> (null (symbol-package tr)))
> then (sync tr)
> else tr))))
> (rfn tree))))
(defun sync-gensyms (tree)
(let ((gensym-pairs nil))
(labels ((sync (g)
(let ((n (symbol-name g)))
(or (cdr (assoc n gensym-pairs
:test #'string=))
(progn
(push (cons n (gensym)) gensym-pairs)
(cdr (assoc n gensym-pairs
:test #'string=))))))
(rfn (tr)
(when tr
(cond
((listp tr)
(cons (rfn (car tr)) (rfn (cdr tr))))
((and (symbolp tr)
(null (symbol-package tr)))
(sync tr))
(t tr)))))
(rfn tree))))