On Mon, Mar 2, 2015 at 10:45 AM, Allen Wirfs-Brock <[email protected]>
wrote:
>
> On Mar 2, 2015, at 9:30 AM, John Lenz wrote:
>
> > I was recently discussion Promise optimizations (specifically, that in
> any "then" chain at least one Promise object is created that goes unused),
> this could be solved by some metadata that indicated whether the result of
> the function would be consumed:
> > ...
> > if (function.called_from_void_result_context) {
> > ...
> > I'm not really sure what impact this would have on the VMs but I found
> it an interesting idea.
>
> Essentially, this means that an additional implicit parameter
> ("calledForValue") needs to be added for every function call. At the MOP
> level this would manifest as an extra argument to the [[Call]] internal
> method. It could be defined to default to true and implementation could
> probably optimize for the default case. But, at least conceptually it
> requires passing additional information across the call boundary. that
> might be a bit much if this is only about optimizing promises.
Allen, sadly, I expect you are correct about this.
Infix ! could, nevertheless, statically expand to .send or .sendOnly
depending on static syntactic context, without any further runtime
implication, as in E.
But .then, being a normal method call rather than distinct "when" syntax,
would not be able to gain a similar benefit.
--
Cheers,
--MarkM
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss