assignment to eval in strict code

Mark Miller erights at gmail.com
Thu Feb 12 17:24:23 PST 2009


On Thu, Feb 12, 2009 at 5:17 PM, Waldemar Horwat <waldemar at google.com>wrote:

> Allen Wirfs-Brock wrote:
>
>> Now that we have decided that all declarations of the identifier "eval"
>> are banned from strict code a related question has come up from one of the
>> implementers of our strict mode prototype implementation.    Why does Es3.1
>> still allow assignment to the identifier "eval" within strict code?   That
>> does seem like a logical extension of the arguments that convinced us to ban
>> strict mode eval declaration.  Does anyone have a reason why such an
>> assignment would be a reasonable thing.
>>
>> Adding that assignment restriction is a bit of a feature creep but
>> something that is probably manageable in the time we have left if the
>> consensus is that it makes sense to do.
>>
>> Thoughts?
>>
>> Allen
>>
>
> How would you ban it?  Would you make every property and variable read-only
> if its name happens to be "eval"?
>

Ban it by a purely syntactic rule affecting only variables, not properties.

    eval = 8;

and

    var eval = 8;

would be statically rejected in strict code, but

    x.eval = 8;

would be fine, even if x turns out to be the global object. Of course, if
other code in that frame has already frozen the 'eval' property of the
global object, then the property assignment would fail as well. But this has
nothing to do with strict mode, and needs no additional machinery in the
ES3.1 spec.

-- 
Text by me above is hereby placed in the public domain

   Cheers,
   --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20090212/db96fe6c/attachment.html>


More information about the Es-discuss mailing list