On Wed, Jun 22, 2011 at 3:01 PM, Sean Eagan <seaneag...@gmail.com> wrote:

> On Wed, Jun 22, 2011 at 12:07 PM, Juan Ignacio Dopazo
> <dopazo.j...@gmail.com> wrote:
> > Can the value of a dynamic super be unambiguously resolved with prototype
> > climbing and without an extra implicit parameter?
>
> Yes, it can be unambiguously determined by prototype climbing, the
> only information from the call site that is used is the base ( |this|
> ) value of the method call or accessor property access, whose
> prototype chain is the one that is climbed.
>
> Cheers,
> Sean Eagan
>

If I understood correctly this thread, the problem seems to be in
distinguishing between |this| and the prototype that "owns" the function.
Let me see if I can explain it...

var A = {
  method: function () { /* do something */ }
};

var B = Object.create(A);
B.method = function () {
  Object.getPrototypeOf(this).method(); // if you do this, then in the
context of A.method |this| will be A, not B
  Object.getPrototypeOf(this).method.call(this); // if you do this, then
it's all ok unless you want add another level
};

var C = Object.create(B);
C.method = function () {
  Object.getPrototypeOf(this).method.call(this); // Now in B.method |this|
will be C and getPrototypeOf will be used with C... an infinite loop
};

IIRC, this is why a |here| value is needed.

Juan
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to