How to escape implicit 'with (this)' of a method body

Peter Hall peter.hall at memorphic.com
Fri Aug 1 02:13:21 PDT 2008


>>
>> In AS3, the reference to bar in the zot function would be bound to
>> this.bar
>
> I don't follow.  There is no `this.bar` in the class where zot is defined.
>

Sorry, I said that backwards. When class foo is compiled, there is no
member called bar, so the reference is bound to the global variable.
Defining a member variable called bar in the subclass does not affect
that.

I don't know how convention will develop in other environments but, in
AS3, global variables are almost always declared in packages, and
strict mode is on by default. The result is that you would always get
a compiler error in these cases instead of an ambiguous reference.

Peter



More information about the Es4-discuss mailing list