> > if Enumerable was a class. But it isn't! > > It's never going to be a class; it was supposed to be a module like in Ruby > language, which is then mixed in certain classes that define _each to get > enumerable goodness.
The Ruby analogy is not going very far anyway: If you change an Enumerable method in Ruby at runtime you see the changes reflected in all Mixees of Enumerable (eg. Hash). In Prototype < 1.5 changes in Enumerable would be reflected at least in new instances of Mixeee classes, since their instances got a copy of the Enumerable methods on creation. Not so in the newer Hash implementation of prototype (starting with 1.5 something) - by manually copying all methods to the "inheriting" classes this runtime flexibility was lost, probably as a trade off for gaining an improved memory footprint. Right? > But with prototypal inheritance in JavaScript that is simply impossible. A > prototype chain is one-dimensional - each object can only inherit from one > prototype. So if an object is already an instance of Hash (for example), it > cannot have dynamic inheritance from Enumerable module. We can only copy > enumerable functions to it. When new functions get added to Enumerable, they > have to be synced manually with target classes. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---