title: Casting anonymous procedures in Delphi 2009
body: <p>The following code (constructed only to demonstrate the problem) compiles and works in Delphi 2010. In Delphi 2009, compiler fails with "E2035 Not enough actual parameters".</p>
  
  <pre><code>program Project50;
  
  {$APPTYPE CONSOLE}
  
  uses
    SysUtils;
  
  type
    TMyProc = reference to procedure(param: integer);
  
  var
    a: TProc;
    b: TMyProc;
  
  begin
    b := procedure (param: integer)
      begin
      end;
    a := TProc(b); // &lt;-- [DCC Error] Project50.dpr(19): E2035 Not enough actual parameters
  end.
  </code></pre>
  
  <p>I have found only one very ugly hack to work around the problem (a: TProc absolute b). Does anybody knows of a nicer workaround for this compiler deficiency?</p>
  
  <p>[TProc field is actually hidden inside a record that can store various 'executable' code - TProcedure, TMethod and TProc. Casting is used to store specific anonymous proc into this field.]</p>