a future caller alternative ?

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Mar 8 13:19:03 PST 2013


I wonder if there's any discussion about it for ES.next

while callee has always been kinda pointless in my opinion, caller property
is not replaceable at all.

Internally, for scope lookup reasons, the caller is always passed somehow,
except, I guess, where there's no caller access and the function is
optimized thanks to absent outer scope look up.

Why caller? Because there's no other way to understand which method invoked
a getter, as the very most basic example.

var obj = Object.defineProperty({}, "caller", {get: function get(){
  return get.caller;
}});

obj.method = function method() {
  alert(this.caller === method);
};

This opens doors to debuggers (introspection) and APIs magic quite a lot.

2 extra points:
  1) I have not even mentioned arguments, which is not mandatory for caller
  2) I haven't used callee and I don't care about callee

Last, but not least, the more I think about the inability to switch "strict
mode" in the wild the more patterns from ES3 injected into ES.next come up
in my mind.

Thanks for any sort of response
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130308/e313b912/attachment.html>


More information about the es-discuss mailing list