eval

Geoffrey Garen ggaren at apple.com
Thu Mar 6 13:59:55 PST 2008


Lars,

Could you comment on this?

I see from your post @ http://www.nabble.com/Eval-invisible-let-bindings-td14182651.html#a14182651 
  that you have definite ideas about "the current ES4 proposal" for  
eval. What is that proposal? Is it written down anywhere?

I tried the reference implementation, but it seems to implement eval  
as a simple string identity operation:

~/src/es4$ ./es4
ECMAScript Edition 4 RI v0.0M2 (Fri Feb 15 13:37:13 2008)
 >> x=1
1
 >> eval('x')
x
 >>

I see some notes written down @ http://wiki.ecmascript.org/doku.php?id=proposals:resurrected_eval 
  and http://wiki.ecmascript.org/doku.php? 
id=discussion:resurrected_eval, but they make no mention of "this",  
and both posts point to open questions, not a finished proposal.

I searched bugs.ecmascript.org but the best thing I found was ticket  
#226, which discusses when ES4-style eval should kick in, not what it  
is.

Is there anywhere else I should be looking?

Thanks,
Geoff

On Mar 5, 2008, at 7:26 PM, Geoffrey Garen wrote:

> Hi all.
>
> I'm trying to implement an ES4-compliant version of eval, but I'm
> having trouble understanding what the specified behavior is.
>
> In ES4,
>
>     eval(x)
>
> is distinct from all of
>
>     window.eval(x)
>
>     eval.call(myThisObject, x)
>
>     frames[0].eval(x)
>
> in that the first form is an operator, and the last three forms are
> function calls.
>
> Right?
>
> OK, for the eval operator, the eval function, the eval function called
> with a specified 'this' object, and the eval function called on
> another global object, respectively:
>
> What scope chain should be used?
>
> What variable object should be used?
>
> What value should 'this' take on?
>
> What gets called if window.eval has been overridden, as in (at global
> scope):
>
> eval = function() { return "overridden"; }
> eval(x);
>
> or
>
> window.eval = function() { return "overridden"; }
> window.eval(x);
>
> What gets called if the "eval" identifier has been shadowed by a
> variable in scope, as in:
>
> with({ eval: function() { return "overridden"; } }) {
> 	eval(x);
> }
>
> or
>
> try {
> 	throw function() { return "overridden"; };
> } catch(eval) {
> 	eval(x);
> }
>
> ?
>
> Thanks,
> Geoff
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss




More information about the Es4-discuss mailing list