On Thu, Jun 19, 2008 at 5:36 PM, Brendan Eich <[EMAIL PROTECTED]> wrote: > On Jun 19, 2008, at 5:14 PM, Mark S. Miller wrote: > >> For example, in ES3 >> >> 11.1.4 Array Initializer >> ... >> 1. Create a new array as if by the expression new Array(). >> ... >> >> The phrase "as if by the expression" followed by a literal snippet of >> code occurs repeatedly in ES3. > > Did you see my message of 16 June, 10:50am? > > https://mail.mozilla.org/pipermail/es4-discuss/2008-June/003020.html
I did see that message, but it doesn't bear on lexical shadowing. Your example there replaces the global binding rather than shadowing it. Did I miss something? >> I know that ES4 prevents assignment to >> the various global variable names used by such code, but what about >> shadowing lexical variable definitions? > > > The wiki page, again, is: > > http://wiki.ecmascript.org/doku.php?id=clarification:which_prototype Yup, that's what I missed. Thanks. That page nowhere says "lexical", "nest", or "shadow" so it hadn't occurred to me that it bore on this issue. > ES4 has gone with memoized original values *and* immutable type bindings, > not name lookup with shadowing hazards, for a long time now. Good. That's what I was hoping you'd say ;). >> FF 2.0.0.14 on squarefree does >> seem to obey the literal reading of the ES3 spec -- that shadowing >> affects array and object literals: >> >> (function foo(){ >> function Array(){return Date;} >> function Object(){return window;} >> return new window.Array([1,2],{bar:3}); >> })(); >> function Date() { [native code] },[object Window] > > Yes, SpiderMonkey followed ES3, as did other implementations, for many > years. Try Firefox 3, it's out now and it uses the memoized original value. > :-) Wonderful! >> Safari literals are not affected by such shadowing definitions. Which >> behavior does ES4 consider correct? > > Lars wrote a spec and iterated on it in this list. Here's the third and > (AFAIK) stable draft: > > https://mail.mozilla.org/pipermail/es4-discuss/2008-April/002668.html > > It too says > > Unlike the case in ES3, the program can't shadow the binding for Object in > order to invoke an alternative object constructor for object initializers. > > NOTE Though ES4 is incompatible with ES3 here, most real-world > implementations of ES3 do not respect shadowing binding for Object when > evaluating object initializers, and the incompatibility is of no > consequence. See [8]. > > I know there's a lot of material to go through, between ES3, ES4 drafts, and > so on -- but it seems like we've been over this topic a lot, and recently > too. In particular in my reply to you of three days ago :-/. Thanks for your patience. And thanks especially for arriving at the right decision on this matter. I agree that the resulting incompatibilities in this case are unlikely to be of any consequence. -- Cheers, --MarkM _______________________________________________ Es4-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es4-discuss
