Newsgroups: comp.lang.clos
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!barmar
From: barmar@think.com (Barry Margolin)
Subject: Re: CLOS Private Methods
Message-ID: <1991Jun26.071539.8418@Think.COM>
Sender: news@Think.COM
Reply-To: barmar@think.com
Organization: Thinking Machines Corporation, Cambridge MA, USA
References: <LGM.91Jun25201133@cbnewsc.ATT.COM> <9106260502.AA11848@kuwait> <42474@ucbvax.BERKELEY.EDU>
Date: Wed, 26 Jun 91 07:15:39 GMT
Lines: 36

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.

This indicates that above methods were misdesigned, or (to give the author
the benefit of the doubt) they were designed to be used as leaf classes,
not as mixins.  In order to allow classes to be mixed together, the methods
have to use (when (next-method-p) (call-next-method ...)) or be implemented
as :before or :around methods (in which case you have to make sure there is
a base class with a primary method).

If the mixins are designed and documented properly, you shouldn't need the
source code to use them.  Unfortunately, there still isn't enough
experience in the industry in proper design and documentation of OO
components, so you end up with code like the above.

-- 
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar
