home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / lisp / x / 292 < prev    next >
Encoding:
Text File  |  1993-01-10  |  1.9 KB  |  52 lines

  1. Newsgroups: comp.lang.lisp.x
  2. Path: sparky!uunet!wupost!cs.utexas.edu!torn!nott!bnrgate!bcars267!bcars267!emcoop
  3. From: emcoop@bnr.ca (hume smith)
  4. Subject: Re: *unbound* in *obarray*
  5. In-Reply-To: emcoop@bnr.ca's message of Tue, 5 Jan 1993 22:44:56 GMT
  6. Message-ID: <EMCOOP.93Jan10163434@bcars148.bnr.ca>
  7. Sender: news@bnr.ca (usenet)
  8. Nntp-Posting-Host: bcars148
  9. Organization: Bell-Northern Research, Ottawa, Canada
  10. References: <21495.1993Jan5.174456@bcars148>
  11. Date: Sun, 10 Jan 1993 21:34:34 GMT
  12. Lines: 38
  13.  
  14. In article <21495.1993Jan5.174456@bcars148> emcoop@bnr.ca (hume smith) writes:
  15.  
  16. >  (let* ((ind (hash "*UNBOUND*" (length *obarray*)))
  17. >     (ls (aref *obarray* ind))
  18. >     (z (car (member "*UNBOUND*" ls :test #'string= :key #'symbol-name))))
  19. >    (unless (boundp 'z)
  20. >      (setf (aref *obarray* ind) (remove "*UNBOUND*" ls :test #'string= :key #'symbol-name))))
  21.  
  22. of course boundp doesn't work right (i.e. the way i wish it did :-)
  23. with "letted" variables...  this all has to be done in the global environment.
  24.  
  25. (setq ind (hash "*UNBOUND*" (length *obarray*))
  26.       ls (aref *obarray* ind)
  27.       z (car (member "*UNBOUND*" ls :test #'string= :key #'symbol-name)))
  28. (unless (boundp 'z)
  29.   (setf (aref *obarray* ind) (remove "*UNBOUND*" ls :test #'string= :key #'symbol-name))))
  30.   
  31. i just LOVE saying stupid things in front of the whole world :-)
  32.  
  33. to make up for it:  here's a definition with-open-stream.  not much use
  34. in `standard' XLisp, but nice with my client and accept accept functions.
  35. and it can be used on an already-open stream, of course...  the uninterned
  36. symbol protects against things like
  37.      (with-open-stream (x z) (setq x 'b))
  38.  
  39. (defmacro with-open-stream (sym-stream &rest body)
  40.   (let ((sym (first sym-stream))
  41.         (stream (second sym-stream))
  42.     (gsym (gensym)))
  43.     `(let* ((,gsym ,stream)
  44.         (,sym ,gsym))
  45.        (unwind-protect 
  46.            (progn ,@body)
  47.          (close ,gsym)))))
  48. --
  49. Hume Smith
  50. hume.smith@acadiau.ca
  51. emcoop@bnr.ca
  52.