[haXe] Reflect.createInstance arguments

Nicolas Cannasse ncannasse at motion-twin.com
Mon Apr 10 13:24:03 CEST 2006


> Hi everyone!
> 
> I'm new to the haXe/NekoVM world and I must say I'm really impressed
> with what I discover. Thanks Nicolas for you work and especially for
> making it so clean and elegant.

Thanks for your thanks ;)

> I'm learning haXe and the Flash API at the same time, so there are a lot
> of things I don't know. I encountered a "Too many arguments" exception
> with Reflect.createInstance with (what I think is) a Flash API class. I
> looked in Reflect.hx and found that there is a hard limit to 5 arguments
> (with an exception for Flash and a silent discarding of excess arguments
> for JS). Is there a particular reason for this ?

Yes you pointed a behavior that is not very coherent accross platforms.
Limiting the number of arguments to 5 is needed since you can't do a
"new apply" with an Array of arguments. You then have to write somethink
like the following in JS :

__new__(cl,args[0],args[1],args[2],args[3],args[4])

In Flash however, I found some cases where a "null" argument is
different from no argument, so I added the switch that makes the
appropriate call depending on the number of arguments.

Such a limitation is not needed in Neko, however I think that the
exception should always be throw for > 5 arguments in order to keep the
API consistent accross platforms. Will fix that now, thanks for reporting.

Nicolas



More information about the Haxe mailing list