Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!mcsun!corton!ircam!jack From: jack@ircam.fr Newsgroups: comp.lang.clos Subject: Re: CLOS Private Methods Summary: Use PreFORM ! Message-ID: <1991Jun26.202149.1346@ircam.fr> Date: 26 Jun 91 20:21:49 GMT References: <20905@sdcc6.ucsd.edu> <1991Jun24.040141.27435@Think.COM> Organization: IRCAM, Paris (France) Lines: 39 In article <1991Jun24.040141.27435@Think.COM> barmar@think.com writes: >[I've redirected followups to comp.lang.clos.] > >In article <20905@sdcc6.ucsd.edu> sboswell@sdcc13.ucsd.edu (....What Is?....) writes: >>How do I make a CLOS method private, so it can only be called by >>other methods in the same class? > >In CLOS, methods are not "in" a class, so there's no notion of methods >being "in the same class". Generic functions invoke methods when the >argument types match the parameter specializers (note the plural). I've implemented a very simple system called PFOOL on top of CLOS. In PFOOL, the dispatching of a generic function to the method depends only on the first argument (called the receiver of the message (guess where it comes from ?)), so methods really belong to some class. Inside the body of a method, the receiver can access to its slots which are all private by default. If you want some object's fields to be read and/or write accessible, you have to provide methods for it. I guess implementing private methods in PFOOL (or using a similar scheme) should not be too difficult. >In general, CLOS doesn't try to implement any information hiding. >SLOT-VALUE, WITH-SLOTS, and WITH-ACCESSORS can be used anywhere (even in >ordinary functions rather than methods). As with the rest of Common Lisp, >the onus is on the programmer to establish and follow programming >conventions, rather than having them be enforced by the language. An "Object Oriented system without any information hiding" !? That seems quite strange (coming from other object systems) ! (Except if you think of CLOS as an assembly language to make higher-level languages) Getting a good style takes a lot of years with a "good" language. It takes even more with "bad" languages. Remember the difference between programs written in Basic and programs written in PASCAL. What about teaching lisp with "goto" instructions instead of structured loops? >Barry Margolin, Thinking Machines Corp. Jacques Duthen (apologize for the English, I need more years...)