> just trying to understand: how is super different from __proto__?

Another way to explain super-calls:

Given a chain of prototypes:
this -> O1 => O2 => O3

Then a super-call is always about letting "this" stay the same, but finding a 
"later" method: If your method lives in O1, you start your search for the 
super-property *after* O1 etc. In code this looks as follows:
    here.__proto__.foo.call(this, …)
where "here" means "the object that the current method lives in". The effect is 
then:
- here.__proto__: start your search *after* the method’s object and look for 
"foo".
- .call(this, …): but keep "this" the same.

"this" must be the same, because the properties usually reside in O1 and every 
method must be able to access those. In other words: Even though you invoke a 
different method, the compound object starting at O1 must be the same.

Two variations that don’t work:
1) this.__proto__.foo.call(this, …)
2) this.__proto__.foo(…)

#1 does not work, because it will *always* start its search in O2 (the 
__proto__ of "this") and not in the object after the method’s object (as it 
should).

#2 does not work, because it will result in "this" being O2 in foo(). Thus, we 
have just lost our properties and cannot change the state of the (compound) 
object, any more.

-- 
Dr. Axel Rauschmayer

[email protected]
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com



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

Reply via email to