On Tue, Aug 27, 2002 at 12:21:00PM +0100, Piers Cawley wrote: > *allowing* classes to be frozen) makes life very hard indeed. And no, > extending via inheritance really doesn't cut it, unless I'm allowed to > say C<Object := NewObject> and force everything that inherits from > Object to inherit from NewObject instead.
Have a look at the language TOM http://www.gerbil.org/tom/ which is a bit like Objective-C and allows precisely that. From the web page: Contemporary object-oriented programming languages employ the class as the unit of reuse. At the same time, the class is also the unit of design. This implies that to reuse a class, the design of the class must fit the design in which it will be reused. While this serves planned reuse, it hampers unplanned reuse. Obviously, unplanned reuse is much more important if widespread reuse is desired. TOM is an object-oriented programming language that advocates unplanned reuse of code. To this effect, TOM enables unplanned reuse through the following features: * A class is defined by its main definition and any extensions. * An extension can add methods, variables, and superclasses to a class. * The source of the original class is not relevant while it is extended: it is not needed and does not need recompilation; nor is recompilation required for any client code or subclasses. Extensions can even be loaded at run time. Unplanned reuse removes the privilege of class modification from the class designer and hands it over as a right to the user. Every user has other uses for a class: the class does not need to suit them all if they can make it suit themselves. Unfortunately the project is quite dead, but the ideas (and perhaps the implementation) are very interesting. -- Bart.