title: AS3: How to force parameters in callback functions
body: <p>I am currently doing something like this:</p>
  
  <pre><code>myFunc(tracer);
  
  function tracer(message:String):void{
   trace(message);
  }
  
  function myFunc(callback:Function):void{
   callback("Hello");
  }
  </code></pre>
  
  <p>Now, this works fine. But how can the function myFunc know, if the given callback function accepts the correct number and type of arguments in its signature?</p>
  
  <p>I want to avoid that I call something like this somewhere in my code:</p>
  
  <pre><code>myFunc(tracer2);
  
  function tracer2():void{
   trace("done");
  }
  
  function myFunc(callback:Function):void{
   // Argument mismatch!
   callback("Hello");
  }
  </code></pre>
  
  <p>Is there a way to do something like this, in order to use compiler warnings/error messages and thus avoid exceptions at runtime?</p>
  
  <pre><code>// Won't work :-(
  function myFunc(callback(message:String):Function):{
   callback("Hello");
  }
  </code></pre>