[Laszlo-dev] Undefined pattern in AS3
André Bargull
andre.bargull at udo.edu
Mon Aug 25 07:04:22 PDT 2008
In my recent changeset for RegExp-support in swf8, you'll get an error,
if you compile the lfc for swf9:
The simple cache class I've added accepts "Objects" as values, so I coded:
> function put (key:String, value:Object) :Object {...}
> function get (key:String) :Object {...}
And in these functions, I've used the "undefined"-pattern described in [1]:
> var old:Object = this.get(key);
> if (*old === void(0)*) {
But this gave me an AS3 compiler-error [2]:
> 1118 Implicit coercion of a value with static type Object to a
> possibly unrelated type void.
To get around the compiler error, I've just changed the type-declaration
to "*" (maybe even more reasonable). So far so good, but we've used the
"void 0"-pattern all along in our code. Therefore do you think it's
possible to update the compiler to change "void 0" to "undefined" for
JS2-targets, resp. the other way around, so "undefined" to "void 0" for
JS1-targets (possibly more straightforward)? Just to ensure the "one
code, multiple runtimes" idea in OpenLaszlo.
- André
[1]
http://pt.withy.org/ptalk/archives/2005/06/dont_assume_undefined_is_undefined.html
[2]
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/compilerErrors.html
More information about the Laszlo-dev
mailing list