[[Invoke]] and implicit method calls

Mark S. Miller erights at google.com
Thu Sep 19 06:07:26 PDT 2013


Not sure I understand this. Would the same [[Get]] + [[Invoke]] behavior be
caused by the following JS pattern:

    if (base[index]) { return base[index](...args); }

as opposed to the [[Get]] + [[Call]] behavior caused by the pattern

    if ((f = base[index])) { f.call(base, ...args); }

(aside from the difference between .call and .[[Call]]) ?

Is it a problem that in the first pattern, the two invocations of
base[index] might return different things?




On Thu, Sep 19, 2013 at 5:32 AM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

>
> On Sep 19, 2013, at 8:05 AM, Brendan Eich wrote:
>
> >> Tom Van Cutsem <mailto:tomvc.be at gmail.com>
> >> September 19, 2013 9:53 AM
> >> 2013/9/19 Allen Wirfs-Brock <allen at wirfs-brock.com <mailto:
> allen at wirfs-brock.com>>
> >>
> >>    I really don't think we need to debate this much longer.  We just
> >>    need to stay the course with [[Invoke]] and I can update the spec.
> >>    to replace [[Get]]+[[Invoke]] rather than [[Get]]+[[Call]] for
> >>    this conditional situations. I may also added add a note
> >>    suggesting that the extra [[Get]] can be eliminated.
> >>
> >>
> >> Refactoring [[Get]]+[[Call]] to [[Get]]+[[Invoke]] seems fine by me. It
> better expresses the intent, and the change should only be observable to
> proxies.
> >
> > Is this so? Wouldn't an ordinary object with a getter be able to observe
> the two lookups? Indeed wouldn't the spec require this?
>
> Yes, the two lookups are observable via a getter.  I mentioned that in a
> comment when I should how the ToPrimitive 'valueOf' invocation might be
> optimized.  However, my argument was that [[Get]]+[[Invoke]] better
> reflects the abstract intent and that intent implicitly includes two
> lookup. I think this difference (from ES<=5.1) is unlikely to be
> significance for the few specific existing cases where this occurs in the
> spec.
>
> Allen
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130919/7d890b17/attachment.html>


More information about the es-discuss mailing list