Tim Olson wrote:
Hi, all:
Here's a cute trick / crufty hack I recently posted to comp.lang.smalltalk. It was in regards to someone complaining that they had to recreate a bunch of methods when using a delegate to implement multiple-inheritance-like operation. Instead of manually doing this (painful) or dynamically doing this by implementing doesNotUnderstand: (slow), why not combine the two and have the doesNotUnderstand: method install the custom-created method?
Comments?
The technique was the basis of Dan Ingalls' and Allan Borning's multiple inheritance system for Smalltalk-80 v2.0. An instance of a class with multiple superclasses checked its extra superclasses for methods in doesNotUnderstand: and recompiled them in its own class so that the next time it was sent there would be no doesNotUnderstand:. The scheme maintained a dependency graph so that if one changed a method (either modified or deleted) that was copied all the copies would be removed. When a class with multiple superclasses was first created for all selectors that had more than one reachable implementation, i.e. ambiguous methods, the class would create a method that did ^self conflictingInheritanceError. The programmer could then resolve the ambiguities as required.
The implementation was buggy; self was not renamed when copying down; conflicting inheritance methods overrode the resolutions if you redefined the class; redefining superclasses could cause bugs due to the traversal machinery expecting a tree and not a graph, etc.
Evewn with these bugs fixed the general feeling was that it was too complex. The best alternative I've seen is Gilad Bracha's mixin-based multiple inheritance scheme. http://java.sun.com/people/gbracha/mwp.html _______________,,,^..^,,,_______________ Eliot Miranda