Hi! I am new to FreePascal/Lazarus (being experienced Delphi programmer, however). Need your help. Maybe this is not the right place for this question, but… I found pretty interesting (and annoying) thing that I cannot explain. Maybe you can help. Take a look at the code:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
...;
type
{ TForm1 }
TForm1 = class(TForm)
...
private
procedure AMethod();
public
end;
...
implementation
{ TForm1 }
type
TMethod = procedure of object;
procedure TForm1.Button1Click(Sender: TObject);
var
m: TMethod;
begin
m:= AMethod; // Get compile time error here!
end;
procedure TForm1.AMethod();
begin
end;
...
end.
I’ve declared TMethod type (procedure of object), and created a method AMethod() that takes no parameters. When I declare a variable of type TMethod and try to assign to that variable my AMethod(), compiler says: “Incompatible types: got “untyped” expected “<procedure variable type of procedure of object; Register>””. Who knows what this is???
Thanks.