Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!cbnewsc!cbnewsc!lgm From: lgm@cbnewsc.ATT.COM (lawrence.g.mayka) Newsgroups: comp.lang.clos Subject: Re: method definition question Message-ID: Date: 19 Jun 91 00:54:05 GMT References: <1991Jun17.210108.29347@Think.COM> Sender: lgm@cbnewsc.att.com (lawrence.g.mayka) Organization: AT&T Bell Laboratories Lines: 29 In-Reply-To: barmar@think.com's message of 17 Jun 91 21: 01:08 GMT In article <1991Jun17.210108.29347@Think.COM> barmar@think.com (Barry Margolin) writes: In article alanr@chopin.media-lab.media.mit.edu (Alan Ruttenberg) writes: >(deftype C () '(or A B)) > >(defmethod common ((instance C)) > ...) > >This doesn't work. (can't find class C) > >My only two choices seem to be to either replicate the code, or to factor the >body of the definition of common into a defun which is called by both. If A and B have any ancestors in common you could define the method on a common ancestor, and then use (check-type instance 'C) to catch misuse. But that's also pretty inelegant. If A and B are standard classes, they are guaranteed to have STANDARD-OBJECT as a common superclass; the method can be specialized on that. And any vendor that allows for run-time modification of the class hierarchy should be able to optimize slot accesses in such a method just as well as in more specialized methods. In an ordinary function, on the other hand, SLOT-VALUE cannot generally be optimized. Lawrence G. Mayka AT&T Bell Laboratories lgm@iexist.att.com Standard disclaimer.