A portable way to tell if a variable is declared special globally

From: Yuji Minejima (ggb01164_at_nifty.ne.jp)
Date: 08/27/04


Date: Fri, 27 Aug 2004 14:13:00 +0900

Hi, all

Is there a portable way to tell if a variable is declared special
globally?

My first shot is the following.
(defun special-variable-p (symbol)
  (assert (symbolp symbol))
  (let ((marker (gensym)))
    (eval `(flet ((special-p ()
                   (and (boundp ',symbol) (eq ,symbol ',marker))))
            (and (not (constantp ',symbol))
                 (let ((,symbol ',marker))
                   (special-p)))))))
This can't distinguish whether it is declared special globally or locally.
And the variable is once bound to a gensymed symbol, which might cause any
trouble if the variable is one of those used by the system like *package*.
Is there any better way to do it?

Regards,

Yuji.