It doesn't look like the runtime allows you to reflect on anonymous functions, which is a shame.
Anonymous functions are (perhaps by definition) marked as dynamic
. If you pass an incompatible type into an anonymous function, no error is thrown. Any type mismatches will be silently cast as best they can. Passing something like "minotaur"
as a uint
parameter will yield 0
(zero), for example.
If you REALLY want to over-engineer it, you could get all OO on it. Instead of accepting anonymous functions, you could declare an interface which contains the appropriate function signature, and accept objects that implement that interface.
public interface IFancyCallback {
public function fancyFunction(frog:Frog, princess:Girl):UsefulReturnType;
}
And your function would just have to be packaged up in an object:
public class ConcreteCallback implements IFancyCallback {
public function fancyFunction(frog:Utensil, princess:Girl):UsefulReturnType {
princess.kiss(frog);
return new UsefulReturnType("jabberwocky");
}
}
Could have the potential to create a lot of code overhead. Depends how many callbacks you intend to have, who's going to be making them, and what how serious it would be if the anon function's signature was incorrect.
Can you share any more about the problem you're trying to solve?