[haXe] default parameters question

Nicolas Cannasse ncannasse at motion-twin.com
Fri Apr 14 17:38:05 CEST 2006


>>>Hi list,
>>>
>>>I have a couple of questions about the code below:
>>>
>>>1. Given that haxe doesn't accept default parameters to functions, how
>>>come the call to myClip.lineStyle(1) works? Is this a bug?
>>
>>This is a special case for flash.* API : all parameters are optional.
> 
> 
> Do you think it would be reasonable to propagate this behaviour to all
> classes extending flash.* classes?

It looks right to me.

Since the special case treat for example all flash.MovieClip methods as
having variable of arguments, you surely would not like to have a fixed
number of arguments when you extends MovieClip.

The current behavior is quite a hack. It's specific to Flash since the
API are designed with a lot of optional arguments, making some of them
painful to use with haXe as long as it doesn't have optional arguments
declaration (and even in that case, there is still a lot of inheritent
Dynamicity in the API).

If you're interested in API design and compile-time error-checking, I
would recommend you to write some API wrappers and only use theses
wrappers instead of Flash API. That would ensure you a more strict API.

BTW if you're interested I just added the -D check_flash_args that
disable this behavior.

Nicolas



More information about the Haxe mailing list