Subject: Re: Comparing C++ and CLOS -- lack of "encapsulation" From: Erik Naggum <email@example.com> Date: 1997/09/02 Newsgroups: comp.lang.lisp,comp.lang.clos Message-ID: <firstname.lastname@example.org> * Adam P. Jenkins | With CLOS, I literally have to read all the code for all the base classes | to make sure I'm not accidentally changing the behaviour of code in the | base classes. It's as if, in C++, I declared every member function | public and virtual. If I were to get, say, a CLOS GUI library, and | wanted to create my own widget by deriving from an existing widget class, | this could be a nightmare. I'd always have to make sure I'm not using | the same name for a method or slot that one of the base classes has but | which was intended to be private, and so wasn't documented. this would be very disturbing if it was true, and you had me very nervous that I had overlooked something this important, but after a careful review of the CLOS specification, I believe you have missed the point that you cannot modify the behavior of functions unless you redefine them, and you wouldn't do that when you have generic functions that would call the method specialized on the types of the actual arguments. thus, if you define a generic function `foo', the generic function is independent of any classes, but you would specialize a method for an object of class `C', which could be the superclass for some subclass `S'. when the time comes to specialize `foo' for objects of class `S', you just do it, and when `foo' is applied to an object of class `S', it will call this new method. until then, you would call the method for `C', but applied to an object of class `C', you would still call the method you defined first. from within the method for `S', you can still call the method for `C' with (call-next-method). (defgeneric foo (x)) (defmethod foo ((x C)) ...) (defmethod foo ((x S)) ...) so either I misunderstood you or you have missed something I think you should take another look at. #\Erik -- 404 You're better off without that file. Trust me.