back2dos / tinkerbell

MIT License
83 stars 8 forks source link

can @:forward could auto add other argument to method? #48

Closed sonygod closed 11 years ago

sonygod commented 11 years ago

can @:forward could auto add other argument to method?

typedef ITest= {

 function say (a:Int, b:String):String;

}

and after @:forward

function say (a:Int, b:String,recall:Void->Void,args:Array):String;

Is that possible?

back2dos commented 11 years ago

This is currently not possible and I'm not sure I understand how this would actually look in practice.

Could you create a gist with a minimal example of what your input is (the type you forward to and the class that uses forwarding) and the final output that you want?

sonygod commented 11 years ago

sorry for delay .. https://gist.github.com/sonygod/5129192

back2dos commented 11 years ago

I am aware that you might want to go in that direction, but I see no sensible way to get this to work. What would the declaration of TestProxy look like? And how do you intend to make sure that the callback is in fact called? Are you using "forward to function"?

As an alternative, I would suggest you return some kind of future from the function, rather than passing additional arguments to it. Your example would then look like this:

test.dropItem(1000).handle(callBack.bind([1000]))

Would that work?

sonygod commented 11 years ago

not work ,such like other tool google buff proto tool it's auto add additional arguments , also I can write other tool to implement that ,but i hopefully it's auto create in code use macro.

sonygod commented 11 years ago

ok,i will try your suggestions ,thanks .