Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!aplcen!ginosko!usc!apple!cambridge.apple.com!bill From: bill@cambridge.apple.com (Bill St. Clair) Newsgroups: comp.lang.lisp Subject: Re: CLOS: is it OOP? Message-ID: <132@brazil.cambridge.apple.com> Date: 15 Sep 89 14:16:56 GMT References: <19582@mimsy.UUCP> Reply-To: bill@brazil.UUCP (Bill St. Clair) Distribution: usa Organization: Apple Computer Inc, Cambridge, MA Lines: 48 In article <19582@mimsy.UUCP> folta@tove.umd.edu.UUCP (Wayne Folta) writes: >I just got Allegro Common Lisp for my Mac, and I have a question concerning >CL's proposed object-oriented extension, CLOS. I have been reading a book >which implies that CLOS can be argued to not be OO: > >"Because CLOS makes no effort at protection or encapsulation, some might >find that it lacks the most essential thing for an object-oriented system." > >"Generic functions are a step away from the concept of active data and back >toward the conventional division between passive data and active process." > >Of course, the author has wonderful things to say about CLOS as well, and >praises its generic-function approach as one of Lisp's great contributions. > >This could start firestorm here, but I don't completely understand OOPS, >and it would be nice to know what experts think about CLOS's OOP-edness. >(Apple's CL has Object Lisp extensions, and I have ordered Xerox's >CommonLOOPS, both of which I understand to be more traditionally "OOP-like" >than CLOS.) Xerox's CommonLOOPS, usually known as PCL (Portable Common LOOPS) is an implementation of CLOS, sans Meta Object Protocol. There ARE some real differences between the object systems you mention, but most of them are syntactic details. CLOS stores a table of methods indexed by type inside of a generic function. Flavors (and Smalltalk, I believe) stores a table of methods indexed by message name inside of a class structure. Object Lisp stores a table of functions indexed by name inside of each instance (it has no real notion of class), and looks up the kindof hierarchy. The only real difference here is the search order (and implementations are free to represent things differently: e.g. a flavors implementation could decide to associate a table of class types with each message name). Object Lisp has the nice feature that an instance can have its own private method not associated with any class, but this is not used very much. CLOS handles this with EQL methods. Yes, CLOS does not provide encapsulation: once a generic function is defined, it's argument pattern is set for all time. Encapsulation is handled by the Common Lisp package system (Here's your chance, all you package system flamers). OOP is a nice way of seperating code into small pieces. It's primary use in my experience is that it allows me to modify the behavior of somebody else's code without actually touching, and potential breaking, the code itself. It also allows me to build basic functionality without worrying about all the little particulars and add them later. The three object-oriented systems that I've used (Flavors, Object Lisp, CLOS) all provide these features. Exactly which details make their way into the standard is not nearly as important to me as that the standard is agreed upon and set so that we can all talk the same language and share our code.