Is it possible to add Function.caller support to Rhino?
Asked Answered
B

1

3

Looking at it, Rhino doesn't support the caller property for functions - does anyone know if there is a branch that allows this, even if just in interpreter mode?

If not, does anyone have any general ideas about how this might be added?

Banter answered 24/1, 2012 at 12:30 Comment(0)
I
0

Never heard about Function.prototype.caller in javascript, but there's arguments.callee.caller, which is really unsupported in Rhino according to the Internet;

If you need to get stack traces, there's an idea for solution: http://groups.google.com/group/mozilla.dev.tech.js-engine.rhino/browse_thread/thread/a8db6d5c4c729f0e/a5f717c02af610ea?pli=1

Impunity answered 24/1, 2012 at 14:13 Comment(4)
arguments.callee just gives you a reference to the current function - therefore arguments.callee.caller is getting the caller property of the current function.Banter
You can get stack traces in Rhino via stack property of the JS error, anyway so I think that's ok.Banter
arguments.callee.caller gets parent-scope function. (function foo() { return (function bar() { return arguments.callee.caller.name) })() })() -> fooImpunity
It gets a reference to the function from which it was invoked - which is not necessarily its parent-scope.Banter

© 2022 - 2024 — McMap. All rights reserved.