home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / lisp / 2382 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.3 KB  |  36 lines

  1. Newsgroups: comp.lang.lisp
  2. Path: sparky!uunet!noc.near.net!news.Brown.EDU!qt.cs.utexas.edu!cs.utexas.edu!sdd.hp.com!ux1.cso.uiuc.edu!m.cs.uiuc.edu!demagog!barbehen
  3. From: barbehen@demagog.cs.uiuc.edu (Michael Barbehenn)
  4. Subject: Re: Selective compilation of reader macro forms...
  5. Message-ID: <1992Sep8.022544.28491@m.cs.uiuc.edu>
  6. Sender: news@m.cs.uiuc.edu (News Database (admin-Mike Schwager))
  7. Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
  8. References: <60132@mimsy.umd.edu>
  9. Date: Tue, 8 Sep 1992 02:25:44 GMT
  10. Lines: 24
  11.  
  12. waander@cs.umd.edu (Bill Andersen) writes:
  13.  
  14. >  I have a reader macro which I want to do two different things depending on
  15. >whether the form following the macro is being compiled, or is being
  16. >entered interactively.  The best way to show this is with an example:
  17. >
  18. >I want to be able to compile a function referencing #$Foo
  19. >without having to worry about an error if "Foo" is not in
  20. >*table* during compilation.  I just want a call to 
  21. >(lookup "Foo") compiled into the function.
  22.  
  23.  
  24. Here's some code that has the flavor of what you are asking for:
  25.  
  26. (defun LOOKUP (name)
  27.   (or (gethash name *table*)
  28.       (error "Sorry, ~s is not in *table*" name)))
  29.  
  30. (defun READ-THING (stream char)
  31.   `(lookup ',(read stream t nil t)))
  32.  
  33. (set-macro-character #\? #'read-thing)
  34.  
  35.  
  36.