Re: portable detection of special symbols?



On 23/04/2011 22:31, Pascal Costanza wrote:
On 23/04/2011 21:07, D Herring wrote:
Special Operator SYMBOL-MACROLET:
"symbol-macrolet signals an error if a special declaration names one of
the symbols being defined by symbol-macrolet"

Is there a better way not requiring the cltl2 environment interface?

Thanks,
Daniel

(defun specialp (symbol)
(eval `(let ((,symbol 0))
(zerop (funcall (let ((,symbol 1))
(lambda () ,symbol)))))))

The following is a variant that moves some code out of the part evaluated at runtime:

(defun specialp (symbol)
(progv (list symbol) '(0)
(zerop (funcall (eval `(let ((,symbol 1))
(lambda () ,symbol)))))))



Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
The views expressed are my own, and not those of my employer.
.