[Laszlo-dev] For Review: Change 20081021-dda-p Summary: Add return type declarations to SWF9
P T Withington
ptw at pobox.com
Tue Oct 21 10:06:27 PDT 2008
Indeed. Being able to declare that a type is actually the type you
declared (does not have this magical extra member which completely
disobeys the type contract) is a tremendously powerful tool for
removing runtime hazards.
On 2008-10-21, at 12:43EDT, André Bargull wrote:
> 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