<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 13, 2009, at 6:20 PM, Ron Garret wrote:</div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font>But I think this is the Right Answer:<br><br>(defmacro defguardian (name)<br> `(defconstant ,name (if (boundp ',name) ,name (gensym))))<br><br>Or if you're really being paranoid:<br><br>(defmacro defguardian (name)<br> `(defconstant ,name (if (boundp ',name) ,name '#.(gensym))))<br></div></blockquote></div><br><div>Bloody hell, that doesn't work either!</div><div><br></div><div>Do this:</div><div><br></div><div><div>(eval-when (:compile-toplevel :load-toplevel :execute)</div><div><br></div><div>(defun noisy-gensym () (format t "~&Calling gensym") (gensym))</div><div><br></div><div>(defmacro defguardian (name)</div><div> `(defconstant ,name (if (boundp ',name) ,name (noisy-gensym))))</div><div><br></div><div>(defguardian foo)</div><div><br></div><div>(defun foo () foo)</div><div><br></div><div>)</div><div><br></div><div>Compile-and-load and observe that noisy-gensym gets called twice (and that foo and (foo) have different values).</div><div><br></div><div>This is getting ridiculous. I humbly submit that there's a case to be made that allowing this kind of behavior is a bug in the standard. Or, failing that, a freedom that it might be wiser to choose to forego. Both CLisp and SBCL do the Right Thing with a simple defconstant. It should not be this hard to make a guardian. In fact, at this point I still don't know a way to do it that actually works in a compiled file in CCL.</div><div><br></div><div>rg</div><div><br></div></div></body></html>