-
Notifications
You must be signed in to change notification settings - Fork 2
Description
It would be good to add a mechanism where constructor chaining is optional.
Doing this is a little complicated, because I don't really want to pass extra parameters to declare() (I want it to be simple: just the constructors and the new prototype).
I can see a case, though, for wanting to create a constructor that doesn't always call of the the parents' constructors. (If anything, so that it's compatible with CoffeScript for example).
If I do this, I will also need to add an easy way to call the super constructor method. Which should be rather trivial. Remember that even in multiple inheritance, constructors are linearised.
So, the practical questions are:
- How do we tell SimpleDeclare not to call the parents constructors?
- What shall we call the "super" attribute? Maybe
__super__? - Should the super attribute be in the prototype? Or attached to the function itself?
- Considering that in multiple inheritance there are copies of the prototypes, should super point to the actual parent, or the copy? (I vote for the copy, as it's always possible to get the copy's
OriginalConstructorattribute)
It will never be as neat as Coffeescript (just typing super() ), but it should be something like this.super() (if we put it in the prototype) or this.constructor.super() (if we put it in the constructor itself).
Calling super() is something that will happen really only if we disable chaining.
I also wonder if instead of having this.super(), we should enhance this.inherited() so that it checks if it's a constructor, rather than a method. This way, we change the API even less...
Ideas?