Thanks Don. I should have tested my prose before posting it. When I did, I got:

>>> Error: Unbound antecedent on line 1 column 42.

Er, if this is a serious question, in LZX methods free references are always looked up in `this` first (as they are in Java). We've come to call that feature 'implicit this'. We regret doing so, because it is not standard Javascript, and people fall into the trap of leaving 'this' off of left-hand-sides, which is dangerous because unless the property already exists in `this`, you will write a global.

`with` is a Javascript primitive that can be used to establish scope. Free variables in the body of a `with` will be looked up first in the object that is the argument (and then in whatever the enclosing scope is). Functions close over their scope when they are defined, so by wrapping `with (_root)` around each global function definition, free references in functions will be looked up in the global context (as opposed to the SWF implementation, where global functions are given a null scope, so when they are called from the idle context, their free references appear unbound).

On 2006-11-16, at 17:18 EST, Don Hopkins wrote:

Which this is that with? Do away with that? What this is that? Implicit this? And what's with?
This is in danger of becoming a "who's on first" routine!

   -Don


with(_root) is not for implicit this. I agree, we should do away with that, but it will be a huge flag day. with(_root) is to get around a swf player 'feature' where global functions have no environment attached to them, so they can't find their free references if invoked from the idle loop.


Reply via email to