Re: double checking if window.eval(…) is an indirect call to eval().

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Sat Aug 27 14:42:51 PDT 2011


On Sat, Aug 27, 2011 at 11:53 PM, John-David Dalton <
john.david.dalton at gmail.com> wrote:

> > No. It's the global object what is the base (more precisely, its DOM's
> proxy wrapper -- `window` or either the global itself), but not an
> environment record.
>
> So basically the only kind of MemberExpression allowed is a
> PrimaryExpression?
>


If it will be easier for you to remember (and what is actually is written in
the reference I gave), _only_ `eval` call written in the following syntactic
form is direct:

eval(...)

Only. _All_ the other cases are indirect.


>
> So writing it out is like:
>  http://es5.github.com/#x8.7.1
>  `window.eval`  -> GetValue(`window.eval`) -> `window` is seen as the
> base so it
>  goes to step 4 of 8.7.1 and not step 5 (which is for environment records).
>
>
Right.


> ES3 makes it a bit more clear:
> "If value of the eval property is used in any way other than a direct
> call (that is, other than by the
> explicit use of its name as an Identifier which is the
> MemberExpression in a CallExpression), or if the
> eval property is assigned to, an EvalError exception may be thrown."
>
>
Yes, perhaps.


> Though older browsers w/ their older implementations will barf on `(1,
> eval)(…)` but not `window.eval(..)` for some reason.
>
>
I think the main word is "may" why it is so. If it would "should", then
maybe implementations would throw SyntaxError in both cases.


> > No, it's indirect.
> >
> >
> http://dmitrysoshnikov.com/ecmascript/es5-chapter-2-strict-mode/#indirect-eval-call
>
> I knew you would chime in with a link to your post, which is why I
> wrote I read the notes associated with the link I posted (your post
> was one of the notes) :P
>
>
Is there something unclear in my explanation? Want to propose to improve
something?

Dmitry.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110828/25171514/attachment.html>


More information about the es-discuss mailing list