Strict mode eval
Allen Wirfs-Brock
allen at wirfs-brock.com
Thu May 12 08:47:14 PDT 2011
On May 12, 2011, at 2:10 AM, Andreas Rossberg wrote:
>
> The one bit where these questions are somewhat related is the
> "(mostly)" bit in your reply. Is there a reason for this "mostly",
> which, I would argue, is a form of dynamic scoping?
>
> /Andreas
The "mostly" refers to the fact the the actual value of the eval binding has to be checked at runtime to be sure that a call via the identifier "eval" is an actual direct eval operation.
For example:
function foo() {
var x=5;
eval("x"); //this looks like a direct eval. Is it really?
}
Needs to "compile" into something like:
function foo() {
var x=5;
if (eval===__builtinEvalFunction__) {
//perform an inline eval operation using the current lexical environment and strict mode
} else eval("x"); //do a regular call to some function that isn't the built-9in eval
}
This is necessary, because the global binding for "eval" might be changed or because there might be a binding of "eval" in an surrounding scope.
Allen
More information about the es-discuss
mailing list