Article View: comp.lang.clos
Article #668CLOS method combination
From: Charles Hornig
Date: Wed, 26 Jun 1991 04:52
Date: Wed, 26 Jun 1991 04:52
39 lines
2090 bytes
2090 bytes
Date: Wed, 26 Jun 1991 03:15 EDT
From: barmar@think.com (Barry Margolin)
References <LGM.91Jun25201133@cbnewsc.ATT.COM>, <9106260502.AA11848@kuwait>, <42474@ucbvax.BERKELEY.EDU>
Reply-To : barmar@think.com
Subject : Re: CLOS Private Methods
In article <42474@ucbvax.BERKELEY.EDU> konstan@elmer-fudd.berkeley.edu (Joe Konstan) writes:
>Re: Encapsulation and fear of packages
>
>I think that the lack of encapsulation problem is more than merely a fear of
>packages. With CLOS, there are many cases where a useful functionality is
>unavailable unless you have (and can modify) the source code to a class and/or
>the methods which specialize on that class. For one example ...
>(defmethod CLEAN ((self HOUSE))
> (wash-windows self)
> (scrub-floors self))
>
>(defmethod CLEAN ((self BOAT))
> (scrape-barnacles self)) ;; I show my ignorance about boats
>
>The default behavior I want for HOUSEBOAT is to do both. I can't do this by
>not defining a method, since neither HOUSE not BOAT does a call-next-method
>and therefore only the first superclass will have its method called.
Here is one possibility:
(defgeneric CLEAN (thing)
(:method-combination progn))
(defmethod CLEAN progn ((self HOUSE))
(wash-windows self)
(scrub-floors self))
(defmethod CLEAN progn ((self BOAT))
(scrape-barnacles self)) ;; I show my ignorance about boats
Note that boats and houses do not have to know about each other.
Technical Details
Message-ID:
<19910626125237.7.HORNIG@MR-WIZARD.SCRC.Symbolics.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!riverside.scrc.symbolics.com!HornigReferences:
<1991Jun26.071539.8418@Think.COM>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.clos Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!riverside.scrc.symbolics.com!Hornig From: Hornig@riverside.scrc.symbolics.com (Charles Hornig) Subject: CLOS method combination Message-ID: <19910626125237.7.HORNIG@MR-WIZARD.SCRC.Symbolics.COM> Sender: daemon@cis.ohio-state.edu Organization: The Ohio State University Department of Computer and Information Science References: <1991Jun26.071539.8418@Think.COM> Date: Wed, 26 Jun 1991 04:52:00 GMT Lines: 39