Article View: comp.lang.lisp.x
Article #327*unbound* in *obarray*
From: hume smith
Date: Tue, 05 Jan 1993 22:44
Date: Tue, 05 Jan 1993 22:44
31 lines
2078 bytes
2078 bytes
prompted by boredom... the only thing i wonder (it just occurred to me) -
if there were no unbound symbols when a garbage collection occurred, would
the special symbol disappear? it's unlikely to happen, but still...
once this is run it's easy to write things that explore the obarray
without tripping over an Unbound Symbol error.
;;; XLisp knows whether a symbol is bound or not by whether a particular
;;; symbol is bound to its value or function field.
;;; that symbol is internal; i.e. in the obarray. this can make for
;;; nasties when you want to manipulate the obarray. it also creates
;;; certain strange situations:
;;; (setq z '*unbound*) -> *unbound*
;;; (boundp z) -> nil
;;; it would probably be better if that symbol were not in the
;;; obarray. the following code safely removes it.
(let* ((ind (hash "*UNBOUND*" (length *obarray*)))
(ls (aref *obarray* ind))
(z (car (member "*UNBOUND*" ls :test #'string= :key #'symbol-name))))
(unless (boundp 'z)
;; it's possible that the special *unbound* had already been removed,
;; in which case z is nil; or that another symbol named *unbound* without
;; the special semantics has been created. the check we just did
;; ensures that the special *unbound* is still in the obarray.
(setf (aref *obarray* ind) (remove "*UNBOUND*" ls :test #'string= :key #'symbol-name))))
--
Hume Smith Wenn ich des Tages nicht dreimal
hume.smith@acadiau.ca mein Schaelchen Coffee trinken darf,
emcoop@bnr.ca // so werd' ich ju zu meiner Qual
\X/ wie ein verdorrtes Ziegenbraetchen.
Technical Details
Message-ID:
<21495.1993Jan5.174456@bcars148>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!torn!nott!bnrgate!bcars267!newsShow Full Headers
Complete Article Headers
Newsgroups: comp.lang.lisp.x Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!torn!nott!bnrgate!bcars267!news From: emcoop@bnr.ca (hume smith) Subject: *unbound* in *obarray* Message-ID: <21495.1993Jan5.174456@bcars148> Sender: news@bnr.ca (usenet) Nntp-Posting-Host: bcars148 Organization: Bell-Northern Research, Ottawa, Canada X-Poster: Emacs-NNTP-0.1 Date: Tue, 5 Jan 1993 22:44:56 GMT Lines: 32