home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / lisp / x / 288 next >
Encoding:
Text File  |  1993-01-06  |  2.0 KB  |  45 lines

  1. Newsgroups: comp.lang.lisp.x
  2. Path: sparky!uunet!usc!cs.utexas.edu!torn!nott!bnrgate!bcars267!news
  3. From: emcoop@bnr.ca (hume smith)
  4. Subject: *unbound* in *obarray*
  5. Message-ID: <21495.1993Jan5.174456@bcars148>
  6. Sender: news@bnr.ca (usenet)
  7. Nntp-Posting-Host: bcars148
  8. Organization: Bell-Northern Research, Ottawa, Canada
  9. X-Poster: Emacs-NNTP-0.1
  10. Date: Tue, 5 Jan 1993 22:44:56 GMT
  11. Lines: 32
  12.  
  13. prompted by boredom...  the only thing i wonder (it just occurred to me) -
  14. if there were no unbound symbols when a garbage collection occurred, would
  15. the special symbol disappear?  it's unlikely to happen, but still...
  16.  
  17. once this is run it's easy to write things that explore the obarray
  18. without tripping over an Unbound Symbol error.
  19.  
  20. ;;; XLisp knows whether a symbol is bound or not by whether a particular
  21. ;;; symbol is bound to its value or function field.
  22. ;;; that symbol is internal; i.e. in the obarray.  this can make for
  23. ;;; nasties when you want to manipulate the obarray.  it also creates
  24. ;;; certain strange situations:
  25. ;;;  (setq z '*unbound*)  ->  *unbound*
  26. ;;;  (boundp z)  ->  nil
  27. ;;; it would probably be better if that symbol were not in the
  28. ;;; obarray.  the following code safely removes it.
  29.  
  30. (let* ((ind (hash "*UNBOUND*" (length *obarray*)))
  31.        (ls (aref *obarray* ind))
  32.        (z (car (member "*UNBOUND*" ls :test #'string= :key #'symbol-name))))
  33.   (unless (boundp 'z)
  34.     ;; it's possible that the special *unbound* had already been removed,
  35.     ;; in which case z is nil; or that another symbol named *unbound* without
  36.     ;; the special semantics has been created.  the check we just did
  37.     ;; ensures that the special *unbound* is still in the obarray.
  38.     (setf (aref *obarray* ind) (remove "*UNBOUND*" ls :test #'string= :key #'symbol-name))))
  39. --
  40. Hume Smith                      Wenn ich des Tages nicht dreimal
  41. hume.smith@acadiau.ca           mein Schaelchen Coffee trinken darf,
  42. emcoop@bnr.ca              //   so werd' ich ju zu meiner Qual
  43.                          \X/    wie ein verdorrtes Ziegenbraetchen.
  44.  
  45.