One of the downsides of the current $super-based implementations is
that it's ridiculously complicated to pass the whole set of arguments
to the parent's method (the equivalent of calling super without
passing any arguments in ruby):

var Child = Class.create(Parent, {
  doStuff: function($super) {
    return $super.apply(null, Array.prototype.slice.call(arguments,
1)) + ' extra stuff';
  }
});

The proposed implementation makes that dead easy and very
JavaScriptish:

var Child = Class.create(Parent, {
  doStuff: function() {
    return this.applySuper('doStuff', arguments) + ' extra stuff';
  }
});

On the other hand, you'd have to handle this like so with your
proposed implementation:

var Child = Class.create(Parent, {
  doStuff: function() {
    return this.getSuper('doStuff').apply(this, arguments) + ' extra
stuff';
  }
});

Which is a lot less elegant imho.

If speed is a concern, we could very well imagine storing a reference
to the superclass's prototype in the sublcass's prototype itself, so
that Class#applySuper could be changed to:

function applySuper(methodName, args) {
  return this._super[methodName].apply(this, args);
}

Finally, adding a base class seems like a good idea.


--~--~---------~--~----~------------~-------~--~----~
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 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to