You can find out if a symbol is bound to a variable with boundp(), but is it possible to detect if the variable is bound in special scope ?
-andré
-andré
Discuss and learn Lisp programming of all dialects
This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.
7 posts · 1597 views
(defvar *debug-store* nil)
(defmacro debug-store (value) `(setf *debug-store* ,value))(if (boundp '*debug*)
(setf (symbol-value '*debug*) local-value))
Happy hackingsinnatagg wrote:Since symbol-value() doesn't see lexical variables I think this is the easiest way.BOUNDP doesn't see lexical variables either, see the note at the end of the Hyperspec entry. This has to be so, because it is a function, and lexical bindings names can be removed at run-time and replaced with direct memory accesses as an optimization during compilation, which is why checking lexical variables information by name requires additional compiler/interpreter support.
(defun variable-special-p (symbol)
"Return T if the symbol names a global special variable."
#+(and allegro (not (version>= 6))) (clos::variable-special-p symbol nil)
#+(and allegro (version>= 6)) (excl::variable-special-p symbol nil)
#+clisp (sys::special-variable-p symbol)
#+cmu (walker:variable-globally-special-p symbol)
#+gcl (si:specialp symbol)
#+lispworks (eq :special (hcl:variable-information symbol))
#+lucid (system:proclaimed-special-p symbol)
#+sbcl (sb-walker:var-globally-special-p symbol)
#-(or allegro clisp cmu gcl lispworks lucid sbcl)
(error 'not-implemented :proc (list 'variable-special-p symbol)))
I'm not sure if this is up-to-date will all the latest implementation internals.