eval on non-strings

Allen Wirfs-Brock allen at wirfs-brock.com
Sun Feb 26 10:32:30 PST 2012

On Feb 26, 2012, at 3:09 AM, Corey Richardson wrote:

> On Sun, 26 Feb 2012 11:57:44 +0100, Xavier MONTILLET <xavierm02.net at gmail.com> wrote:
>> Or it should call its toString method.
> That would introduce unwanted side effects. Sondier this:
> eval([1, 2, 3]) right now returns [1, 2, 3]. But [1, 2, 3].toString() is
> '1,2,3', so you'd have eval('1,2,3') which returns 3. That makes even less
> sense than just returning what was given.
> I really don't think anything but an exception is good there (perhaps limited
> to strict mode or something?)

Like all breaking changes, we would need to consider and gather evidence regarding whether  it would have significant impact on current web content. Is the current behavior so detrimental that we should divert energy into that task?  

The change can't be predicated on strict code because it concerns the definition of a built-in function that is called from any code. Strict mode restrictions must be tied to a lexical context.


More information about the es-discuss mailing list