eval operator with != 1 arguments

Mark S. Miller erights at google.com
Fri Jan 15 20:39:37 PST 2010

On Fri, Jan 15, 2010 at 7:11 PM, Brendan Eich <brendan at mozilla.com> wrote:
> On Jan 15, 2010, at 5:49 PM, Mike Samuel wrote:
>> 2010/1/15 Brendan Eich <brendan at mozilla.com>:
>>> On Jan 14, 2010, at 6:27 PM, Mike Samuel wrote:
>>>> Any thoughts on whether (eval(a, b)) should be an invocation of the
>>>> eval operator?
>>> What do current browsers do? It's an eval operator in Mozilla-based
>>> browsers. Seems to be eval (dynamic scope, not global scope) in Safari
>>> too.
>>> What would be the benefit of changing a future edition to make such an
>>> eval
>>> "indirect"?
>> I am not advocating changing eval in a future edition.
>> What I found confusing was that the previous section started with
>>   "When the eval function is called with one argument x, the
>> following steps are taken:"
>> and whether that was assumed by the following section.
>> But somebody here read and concluded that eval with other
>> than one argument was the function.

"Somebody here" was Tom and I, with the misunderstanding probably being by me.

>> I concluded otherwise.  I still don't know what the answer is?
> " Direct Call to Eval" does not care about number of actual
> arguments, only about the two conditions:
> "The Reference that is the result of evaluating the MemberExpression in the
> CallExpression has an environment record as its base value and its reference
> name is "eval".
> The result of calling the abstract operation GetValue with that Reference as
> the argument is the standard built-in function defined in"
> So ES5 says eval(s, x) is a direct call.
> "When the eval function is called with one argument x, the following steps
> are taken" is misworded -- it wants to introduce the metavariable x but it
> overspecifies for the case of exactly one argument. In fact eval() returns
> undefined per the specified semantics, and so does eval(undefined, {}). And
> at least Firefox and Safari eval(s, {}) where s is a string as a direct eval
> call.

Good. Once Mike pointed out the issue, that's what we figured the
answer was likely to be. We are happy with that answer.

> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list