I have done some horrible code where I needed to know the following:<br><br>If TSomeProc = procedure(....), then is it easy to determine or set entry vector of ThatProc: TSomeProc by stating ThatProc := @ProcWhereTheCodeLives_InTheCodeSegment;<br>
<br>It gets more difficult when you work with TSomeClassProc = procedure(....) of object, because two parts are referenced here: 1) The entry vector where the code lives, 2) The heap address where the object struct lives. (Known as the Self variable in a procedure of object)<br>
<br>I have worked out which pointer of the two pointers belongs to the code and which to the instance with a trial. With a move operation, I was able to manipulate the two pointers, specifically to determine the address of the instance.<br>
<br>The @ operator only gives you access to the procedure part. Is there, or will there be, another operator to give you access to the instance address?<br><br><div class="gmail_quote">2009/9/10 Mattias Gärtner <span dir="ltr"><<a href="mailto:nc-gaertnma@netcologne.de">nc-gaertnma@netcologne.de</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Zitat von Vincent Snijders <<a href="mailto:vsnijders@vodafonevast.nl" target="_blank">vsnijders@vodafonevast.nl</a>>:<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Jonas Maebe schreef:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
On 10 Sep 2009, at 14:01, Mattias Gärtner wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Mattias Gärtner wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Can someone explain why in mode objfpc comparing methods only compares<br>
the address, but not the instance?<br>
</blockquote>
<br>
Seems perfectly logical to me (@ = Address of, in this case "code<br>
address", the code is the same for all instances of a class).<br>
</blockquote>
<br>
OnClick:=@MyClick;<br>
<br>
The @ operator is more than "address of".<br>
</blockquote>
<br>
The current behaviour has been there since svn revision 1, so it's quite old and established at least (and Delphi/TP-compatible, afaik).<br>
</blockquote>
<br>
It is delphi compatible, not really intuitive, so I would welcome a change in the objfpc mode.<br>
<br>
See:<br>
<a href="http://bugs.freepascal.org/view.php?id=9228" target="_blank">http://bugs.freepascal.org/view.php?id=9228</a><br>
<a href="http://bugs.freepascal.org/view.php?id=11868" target="_blank">http://bugs.freepascal.org/view.php?id=11868</a><br>
</blockquote>
<br></div>
To draw the whole picture:<br>
<br>
var a,b: TNotifyEvent;<br>
<br>
a=b compares only Code, not Data<br>
a=nil compares only Data, not Code<br>
Assigned(a) compares only Code, not Data<br>
n.a. compares both<br>
<br>
I wonder how many programmers know this.<br>
<br>
Even the FCL contains code, where this leads to wrong code.<br>
More important: I don't know a place, where a=b and a=nil are used right. But I have seen a lot of code where it was used wrong.<br><font color="#888888">
<br>
<br>
Mattias</font><div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org" target="_blank">fpc-devel@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-devel" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-devel</a><br>
</div></div></blockquote></div><br>