Closed Bug 352045 Opened 18 years ago Closed 16 years ago

remove Object.prototype.eval

Categories

(Core :: JavaScript Engine, defect)

x86
Windows 2000
defect
Not set
minor

Tracking

()

RESOLVED DUPLICATE of bug 382509

People

(Reporter: geckobugs, Unassigned)

References

()

Details

User-Agent:       Opera/9.01 (Windows NT 5.0; U; en)
Build Identifier:  Minefield 3.0a1/20060908

Having eval() in scope of every object is officially deprecated. It should be removed.

Documentation:
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object:eval

Discussion regarding Opera bug report:
http://my.opera.com/hallvors/blog/show.dml/449976

Reproducible: Always
Status: UNCONFIRMED → NEW
Ever confirmed: true
We've talked about this in ECMA TG1.  My colleague from Opera reports that it is necessary to support indirect eval of the form w.eval for any window object w. But cross-browser JS does not require o.eval for any object o.  However, at least Venkman and probably many other XUL apps and extensions depend on this old SpiderMonkey feature (it goes back to the dawn of JS, 1995).

Object.prototype.eval is something we definitely want to remove, so this bug is good to have on file (is there an older one it dups, though? I have memories of another bug like this).  The Mozilla milestone in which to do this is Mozilla 2, when we can make big API compatibility breaks (not break all API compatibility promises, just big/old/deep ones like this particular one).  Mozilla 2 work should start soon; I'll have more to say about this within the next few weeks.

For ES4/JS2 we are considering support for eval(s, o) -- an optional second argument giving the scope chain (not an object to extend the scope chain, as SpiderMonkey does now via an internal translation to with(o)eval(s)) for the evaluation of s.

/be
(In reply to comment #1)
> Object.prototype.eval is something we definitely want to remove

The docs say it actually *was* removed in JS1.4. Was it removed and reinstated, or never removed?

(In reply to comment #2)
> (In reply to comment #1)
> > Object.prototype.eval is something we definitely want to remove
> 
> The docs say it actually *was* removed in JS1.4. Was it removed and reinstated,
> or never removed?

The docs lie.  There's no trace in jsobj.c's CVS history (cvs annotate -rN jsobj.c | grep obj_eval and back N up to one before each change) that did not define eval as an Object.prototype method.  The incompatibility would have been as painful, or moreso, then than now.

/be
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > Object.prototype.eval is something we definitely want to remove
> > 
> > The docs say it actually *was* removed in JS1.4. Was it removed and reinstated,
> > or never removed?
> 
> The docs lie.  There's no trace in jsobj.c's CVS history (cvs annotate -rN
> jsobj.c | grep obj_eval and back N up to one before each change) that did not
> define eval as an Object.prototype method.  The incompatibility would have been
> as painful, or moreso, then than now.
> 
> /be
> 

I've fixed the docs.
Isn't this a duplicate of bug 382509?
Yeah, duping forward.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.