In Flex 3,
var anInstance : MyClass = new MyClass(); with (anInstance) { property1 = 'fred'; property2 = 5; propert3 = 7; }
does NOT flag ‘propert’ as a non-existent property name. I thought this was a remainder of the evil JavaScript object behavior (referring to a property name of an object implicitly creates it), but it seems to be a side-effect of the ‘with’.
This makes me very sad as the ‘with’ was a little reminder of Delphi (except it works correctly there).
Am I missing something here?
From reading the documentation:
Actionscript apparently bubbles out for scope resolution on embedded variables (not surprising, since the syntax doesn’t require an explicit dereference symbol like ‘.’ or ‘->’ to indicate which variable names should be ‘withed’.) So you effectively are creating a variable at global scope named propert3.
EDIT after thinking about why this ‘problem’ exists –
Javascript is the epitome of non-strict typing. And Actionscript, being a strict superset of Javascript, can’t enforce strict typing except as declared by its own extensions to the language – which means it must support untyped variables.