On Aug 21, 2008, at 7:55 PM, David-Sarah Hopwood wrote: >>> If it were dynamic, then you'd expect: >>> >>> function setOptionB(x) { >>> print(x == opt_B); >>> } >>> >>> setOptions({opt_B: 42}); >>> >>> to print true, but it actually prints false. >> >> I don't see how. Dynamic scope means the caller's environment is >> visible >> to the callee. > > Yes, exactly. In your example, the caller's environment is not > visible to > the callee for any of the calls.
I know. But in your example above, opt_B in the _ context in setOptions({_: 42}); is not a binding. So if dynamic scope were the rule for JS, the print would still print false because the outer opt_B is initialized to 0. Probably I'm missing your meaning. The dynamic part here is that with means you can't make static binding judgments, as you can in lexically scoped languages such as Scheme or JS without with, eval, and the global object. >> But an object initialiser passed as an actual argument >> does not bind any of its properties in the caller's environment. > > No, but the 'with' hypothetically would, if it provided dynamic > scoping. Oh, I see. That is not what I thought you meant. 'with' is not a binding form, so the hypothesis fails in my view. > It's quite easy to imagine a 'with'-like construct that could work in > this way, in a language that was otherwise dynamically scoped, or if > the use of 'with' were to insert a scope in the lexical chain not > dependent on the with's lexical position. (Yes, that would be awful.) Gotcha, and agreed. >> I've never heard of lexical scoping with conditional shadowing. > > I just made up the term, but it's as good a description as any. I don't think it's lexical scoping, period. http://en.wikipedia.org/wiki/Lexical_scope#Static_versus_dynamic_scoping > I don't know of anything that works like 'with' in any other > programming > language. Various Borland languages and BASIC dialects had a WITH, if memory serves. In fact some ex-Borland people at Netscape advocated for with in spring, 1995, citing long property references starting with document. -- and I gave it to them... :-/ /be _______________________________________________ Es-discuss mailing list Es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss