Lars Hansen wrote: > In my opinion the following is roughly right: > > obj.eval(x) > if eval is the original global eval function then > if obj is an ES global object (window, frame) then > invoke eval as follows: > the scope chain holds that window (global) object only > the variable object is that window object > the value of "this" is that window object > else > this is an error > else > we don't care; invoke the method eval on obj > > eval(x) > look up "eval" > if the found value v is the original eval function and > the binding object x holding eval is an ES global object and > the global object on the scope chain for v is x then > invoke eval as follows: > the scope chain is the lexical chain in effect at the point of > invocation > the variable object is the innermost variable object in effect > (which is to > say that it excludes binding objects introduced for "let", > "catch", named > function expressions, "switch type", and note also that > code at the top > level of a class is static initialization code so the > variable object > is the global object) > the value of "this" is the global object x > else > we don't care; invoke v as a normal function
Seems reasonable, although anything dealing with eval evil can get tricky. What about the other cases such as: obj.foo(x) foo(x) new foo(x) where foo happens to contain the original eval function. Do you try to do the eval, throw an EvalError, or do something else? ES3 gave the implementations a choice of either doing the eval or throwing an EvalError. Waldemar _______________________________________________ Es4-discuss mailing list Es4-discuss@mozilla.org https://mail.mozilla.org/listinfo/es4-discuss