Re: portable detection of special symbols?



In article <91gs4vF3hpU1@xxxxxxxxxxxxxxxxxx>,
Pascal Costanza <pc@xxxxxxxxx> wrote:

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

Doesn't work:

? (defconstant x 1)
X
? (defun specialp (symbol)
(progv (list symbol) '(0)
(zerop (funcall (eval `(let ((,symbol 1))
(lambda () ,symbol)))))))
SPECIALP
? (specialp 'x)
Error: (X) is not a proper list of bindable symbols of length < 169.

rg
.