Am 24.10.2017 14:57 schrieb "Giuliano Colla via Lazarus" < lazarus@lists.lazarus-ide.org>:
Il 24/10/2017 14:15, Mattias Gaertner via Lazarus ha scritto: > On Tue, 24 Oct 2017 13:56:43 +0200 > Giuliano Colla via Lazarus <lazarus@lists.lazarus-ide.org> wrote: > > > [...] >> >> Now the catch is that the queue used is just a queue of pointers, while >> here we're dealing with procedures of object. This is legal with Delphi >> syntax, while it is forbidden in ObjFpc. >> > It's only legal with a typecast. > You can typecast a procedure of object to a pointer, but not the opposite. And that is good. > When I tried to see if the >> problem was originated by Delphi mode, and changed to objfpc mode, it >> turned out that there was no way to make it compile. >> > The compiler tried to protect you from shooting yourself in the foot. > > Yes, but not in Delphi mode. But just changing >> my queue from a queue of pointers to a queue of TProc (TProc = procedure >> of object) fixes the issue: it compiles, it works, Self is correct, >> there's no need to qualify the identifier, and all is well. >> >> The moral of the story is: in Delphi mode you can assign a procedure of >> object to a pointer, and the compiler doesn't complain, but it is wrong, >> > I just tried with $mode delphi: > > p:=o.DoIt; > > test1.pas(32,4) Error: Invalid assignment, procedures return no > value > But in Delphi mode @NextProc := Coda.Remove; Sending := True; NextProc; with NextProc defined as a procedure of object does compile but it's wrong. Why are you using an @ when you assign the NextProc variable? O.o Regards, Sven
-- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus