home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / lisp / 2124 < prev    next >
Encoding:
Text File  |  1992-07-27  |  2.2 KB  |  60 lines

  1. Newsgroups: comp.lang.lisp
  2. Path: sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!phil
  3. From: phil@Xenon.Stanford.EDU (Phil Stubblefield)
  4. Subject: Help with EVAL-WHEN
  5. Message-ID: <1992Jul28.033744.13313@CSD-NewsHost.Stanford.EDU>
  6. Summary: How to conditionally DEFGENERIC, etc.?
  7. Originator: phil@Xenon.Stanford.EDU
  8. Sender: news@CSD-NewsHost.Stanford.EDU
  9. Organization: Computer Science Department, Stanford University.
  10. Date: Tue, 28 Jul 1992 03:37:44 GMT
  11. Lines: 47
  12.  
  13. I'm working on some software intended to run in several different
  14. implementations.  In some of the implementations, a useful function FOO is
  15. defined.  In the others, FOO is undefined, and so I've provided my own
  16. definition.  What I'd like to be able to do is to execute my definition if
  17. and only if the implementation doesn't already provide its own.
  18.  
  19. My code is isomorphic to the following:
  20.  
  21. (eval-when (:compile-toplevel :load-toplevel :execute)
  22.   (unless (fboundp 'foo)
  23.     (eval-when (:compile-toplevel :load-toplevel :execute)
  24.  
  25.       (defconstant +used-to-compute-foo+ ...)
  26.  
  27.       (defgeneric foo (object))
  28.  
  29.       (defmethod foo ((object t))
  30.         <code that uses the previously defined constant>)
  31.  
  32.       <more method definitions...>
  33.  
  34.       )))
  35.  
  36.  
  37. At compile time under Franz Allegro CL 4.1 running on a SparcStation, I am
  38. warned that the symbol +used-to-compute-foo+ is being declare special.  At
  39. load time, I get the following error (reformatted):
  40.  
  41. Error: No methods applicable for generic function
  42.        #<STANDARD-GENERIC-FUNCTION FIND-METHOD @ #x862e0e> with
  43.        args (#<Function FOO @ #xb1f72e> NIL
  44.        (#<BUILT-IN-CLASS SEQUENCE @ #x78b356>) NIL)
  45.        of classes (FUNCTION NULL CONS NULL)
  46.   [condition type: PROGRAM-ERROR]
  47.  
  48. Clearly, I have a incomplete and/or flawed model of EVAL-WHEN.  Can someone
  49. enlighten me?
  50.  
  51. (For those who care, the actual instantiation of this problem uses the
  52. function CLIM:PRESENTATION-TYPE-OF, which is defined in CLIM 1.1 but not in
  53. CLIM 1.0.  Unfortunately, I know of no easy way to discriminate between the
  54. two releases.)
  55.  
  56. -- 
  57.  
  58. Phil Stubblefield                                        (415) 325-7165
  59. Rockwell Palo Alto Laboratory                    phil@rpal.rockwell.com
  60.