Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!news.media.mit.edu!news.media.mit.edu!alanr From: alanr@chopin.media-lab.media.mit.edu (Alan Ruttenberg) Newsgroups: comp.lang.clos Subject: method definition question Message-ID: Date: 17 Jun 91 18:08:03 GMT Sender: news@news.media.mit.edu (USENET News System) Organization: MIT Media Laboratory Lines: 40 I have a question concerning creating a method applicable to one of two classes. Suppose I have two classes A and B. These two classes are distinct. They happen to share similar instance variables, but it is not possible to factor this out to a mixin, since I can't redefine A. I want to write a method which is applicable to either. The cleanest way to express it is: (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. 1- (defmethod common ((instance A)) the code) (defmethod common ((instance B)) the same code) 2- (defmethod common ((instance A)) (the-code instance)) (defmethod common ((instance B)) (the-code instance)) (defun the-code (instance) the code) So the question is... Is there a more elegant way to do this? -alan