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

  1. Path: sparky!uunet!haven.umd.edu!mimsy!waander
  2. From: waander@cs.umd.edu (Bill Andersen)
  3. Newsgroups: comp.lang.lisp
  4. Subject: Selective compilation of reader macro forms...
  5. Message-ID: <60132@mimsy.umd.edu>
  6. Date: 7 Sep 92 07:53:49 GMT
  7. Sender: news@mimsy.umd.edu
  8. Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
  9. Lines: 38
  10.  
  11.  
  12.   I have a reader macro which I want to do two different things depending on
  13. whether the form following the macro is being compiled, or is being
  14. entered interactively.  The best way to show this is with an example:
  15.  
  16. (defun lookup (name)
  17.   (or (gethash name *table*)
  18.       (error "Sorry, ~s is not in *table*" name)))
  19.  
  20. (defun read-thing (stream sub-char infix-arg)
  21.   ...read name as a string from <stream>
  22.   ...call (lookup <name>)
  23.   )
  24.  
  25. (set-dispatch-macro-character #\# #\$ 'read-thing)
  26.  
  27. ==========
  28.  
  29. I want to be able to compile a function referencing #$Foo
  30. without having to worry about an error if "Foo" is not in
  31. *table* during compilation.  I just want a call to 
  32. (lookup "Foo") compiled into the function.  Example of
  33. how this should work follows:
  34.  
  35. > #$Foo 
  36. #<thing named "Foo">
  37.  
  38. > (defun doit () #%Foo)
  39. DOIT
  40.  
  41. > (doit)
  42. #<thing named "Foo">
  43.  
  44. ==========
  45.  
  46.   Thanks in advance...
  47.  
  48.   ...bill
  49.