[Laszlo-dev] For Review: Change 20081021-dda-p Summary: Add return type declarations to SWF9
André Bargull
andre.bargull at udo.edu
Tue Oct 21 09:43:26 PDT 2008
It's so sad that Adobe didn't integrate Nullable types into AS3.
On 10/21/2008 6:23 PM, P T Withington wrote:
> I just made the same observation in my review (not yet finished):
>
> lzx> (function ():Boolean { return void 0; })()
> false
> lzx>
>
> If I try this same test with Number for Boolean in the debugger, it
> seems to fail silently.
>
>
> On 2008-10-21, at 12:20EDT, André Bargull wrote:
>
>> If a function's return type is Number, you must not return ?undefined?:
>> - either remove the return type
>> - or return ?NaN?
>> (Because AS3 coerces ?undefined? automatically to ?NaN?. By returning
>> 'undefined', we'll get different behaviour across runtimes.)
>> For example LzAudio#getVolume(), LzAudio#getPan() and the counterparts
>> in LzView.
>>
>> I guess it's the same with Boolean. So if the return type is Boolean,
>> returning 'undefined' will produce different behaviour across runtimes.
>> For example in LzAnimatorGroup/LzAnimator#update(), #checkRepeat() you
>> can safely return ?false?.
>>
>
More information about the Laszlo-dev
mailing list