Xref: utzoo comp.lang.misc:4852 comp.lang.smalltalk:1859 Path: utzoo!attcan!uunet!hsi!stpstn!andyn From: andyn@stpstn.UUCP (Andy Novobilski) Newsgroups: comp.lang.misc,comp.lang.smalltalk Subject: Re: Languages that allow extensions to classes Message-ID: <4482@stpstn.UUCP> Date: 12 Apr 90 15:33:01 GMT References: <16560@estelle.udel.EDU> Reply-To: andyn@stepstone.com (Andy Novobilski) Organization: The Stepstone Corporation, Sandy Hook, CT 06482 Lines: 43 In article <16560@estelle.udel.EDU> new@ee.udel.edu (Darren New) writes: >One feature of Smalltalk that I really like and use is the ability to >put methods from one class into several files. This allows, for example, >for the extention of already-defined classes with new methods. > >... In Objective-C, I don't know if this is possible, especially without > the sources to the other methods. > ... >Is my analysis of C++, Objective-C, and Eiffel correct? ... Darren, The Objective-C language supports the extension of pre-existing classes and class libraries by allowing one class to "pose" as another. This mechanism is invoked at runtime by the Objective-C object model and allows a programmer to insert behavior (no data) into the class hierarchy structure. The programmer uses the poseAs capabilities by defining a new class (methods only, no instance variables allowed) that sends a "poseAs:" message at initialization time indicating the class it wishes to pose as. This causes the message lookup function to check if the method is located in the posing class before checking in the original class that was posed as. The pose as functionality is made possible by Objective-C's use of dynamic binding to resolve what method should supply the requested behavior at message time. The use of dynamic binding also allows a programmer to change the methods of a class definition without having to recompile classes that subclass from it. However, if a change is made to an instance variable, then all subclasses of that class must be recompiled. If you have any additional questions, please feel free to contact us (or myself) at Stepstone. Andy N. -- Andy Novobilski | The Stepstone Corp. | The expressed views have been andyn@stepstone.com | 75 Glen Rd. | approved by a committee of three: (203)426-1875 | Sandy Hook, CT 06482 | the goldfish, blackfish, and me.