Here is another test, a bit more complex. It fails when trying to pass a procedure reference to the Execute<T, A>. This is a bit different than trying to get a reference to a generic routine. Routines like ControlMove and ShapeColor and not generic.
{$mode delphi} type TForEach<T, A> = procedure(Item: T; Arg: A); // inside TMainForm declaration procedure Execute<T: TComponent; A>(ForEach: TForEach<T, A>; Arg: A); // implementation procedure TMainForm.Execute<T, A>(ForEach: TForEach<T, A>; Arg: A); var I: Integer; begin for I := 0 to ComponentCount - 1 do if Components[I] is T then ForEach(Components[I] as T, Arg); end; procedure ControlMove(Item: TControl; Arg: Integer); begin Item.Left := Arg; end; procedure ShapeColor(Item: TShape; Arg: TColor); begin Item.Brush.Color := Arg; end; procedure TMainForm.ExecuteButtonClick(Sender: TObject); begin // below fails after "Integer>" with Compilation raised exception internally Execute<TControl, Integer>(ControlMove, Mouse.CursorPos.X); if ColorDialog.Execute then Execute<TShape, TColor>(ShapeColor, ColorDialog.Color); end;
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal