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