home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.lisp
- Path: sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!phil
- From: phil@Xenon.Stanford.EDU (Phil Stubblefield)
- Subject: Help with EVAL-WHEN
- Message-ID: <1992Jul28.033744.13313@CSD-NewsHost.Stanford.EDU>
- Summary: How to conditionally DEFGENERIC, etc.?
- Originator: phil@Xenon.Stanford.EDU
- Sender: news@CSD-NewsHost.Stanford.EDU
- Organization: Computer Science Department, Stanford University.
- Date: Tue, 28 Jul 1992 03:37:44 GMT
- Lines: 47
-
- I'm working on some software intended to run in several different
- implementations. In some of the implementations, a useful function FOO is
- defined. In the others, FOO is undefined, and so I've provided my own
- definition. What I'd like to be able to do is to execute my definition if
- and only if the implementation doesn't already provide its own.
-
- My code is isomorphic to the following:
-
- (eval-when (:compile-toplevel :load-toplevel :execute)
- (unless (fboundp 'foo)
- (eval-when (:compile-toplevel :load-toplevel :execute)
-
- (defconstant +used-to-compute-foo+ ...)
-
- (defgeneric foo (object))
-
- (defmethod foo ((object t))
- <code that uses the previously defined constant>)
-
- <more method definitions...>
-
- )))
-
-
- At compile time under Franz Allegro CL 4.1 running on a SparcStation, I am
- warned that the symbol +used-to-compute-foo+ is being declare special. At
- load time, I get the following error (reformatted):
-
- Error: No methods applicable for generic function
- #<STANDARD-GENERIC-FUNCTION FIND-METHOD @ #x862e0e> with
- args (#<Function FOO @ #xb1f72e> NIL
- (#<BUILT-IN-CLASS SEQUENCE @ #x78b356>) NIL)
- of classes (FUNCTION NULL CONS NULL)
- [condition type: PROGRAM-ERROR]
-
- Clearly, I have a incomplete and/or flawed model of EVAL-WHEN. Can someone
- enlighten me?
-
- (For those who care, the actual instantiation of this problem uses the
- function CLIM:PRESENTATION-TYPE-OF, which is defined in CLIM 1.1 but not in
- CLIM 1.0. Unfortunately, I know of no easy way to discriminate between the
- two releases.)
-
- --
-
- Phil Stubblefield (415) 325-7165
- Rockwell Palo Alto Laboratory phil@rpal.rockwell.com
-