On Oct 3, 2011, at 5:15 PM, Quildreen Motta wrote:

> On 03/10/11 20:44, Axel Rauschmayer wrote:
>> super being rare and moving methods being rarer, I think the tradeoff for 
>> performance is OK, especially as there will be a method that allows you to 
>> move methods. If performance wasn’t an issue, dynamic "super" would be 
>> preferable.

Axel has this exactly right.  Ideally, a super property lookup would be a 
dynamic continuation of the property lookup. However, enabling such a dynamic 
lookup continuation imposes what is generally considered to be an unacceptable 
tax on every function invocation.  Having a method statically capture its 
lookup continuation point is a slightly less flexible solution but it 
eliminates the every call tax.  Every object-oriented language that I'm 
familiar with define the semantics of super using this static binding 
semantics. 

Calling a function that does a super lookup using direct invocation rather than 
via a method invocation is inherently bogus. super.foo means lookup foo 
starting at the continuation point of the lookup that retrieved the currently 
executing method.  If there was no such lookup to continue, super.foo has no 
"correct" semantics because. Don't do it!  In fact the static [[Super]] binding 
semantics does specify what will happen.  But if a programmer intentionally 
coded this in a function that is expected to be called via direct invocation 
then they have a design bug. 

> Hm, I wouldn't consider moving methods to be that rare, unless you're taking 
> into account only people coding in a declarative style. In that case, moving 
> a method would be a weird thing to do. On the other hand, if you're writing 
> imperative prototypical code, moving methods might not be such a rare thing — 
> more so if we take into account the lack of multiple-inheritance facilities 
> in JS, which would lead someone to use things like mixins (thus, more 
> overhead due to manual copying, but mixins are — or should be — parentless 
> anyways).

The think to remember is to use Object.defineMethod anytime you want copy a 
method from one object to another.  Even this the method doesn't contain a 
super refer.  (Who knows, it might tomorrow).

Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to