Mattias Gärtner wrote:
Zitat von Michael Schnell <mschn...@lumino.de>:
Mattias Gärtner wrote:
Can someone explain why in mode objfpc comparing methods only compares
the address, but not the instance?
Seems perfectly logical to me (@ = Address of, in this case "code
address", the code is the same for all instances of a class).
OnClick:=...@myclick;
The @ operator is more than "address of".
Most interesting.
I also always sought @Instance.Method, returns a TMethod record (that is
the address of the instance and the address of the Code).
But mor interesting: There a various mails/requests about:
- overloading by result
- automatic extending a calculation to the type of the result AInteger
:= AByte + AByte can cause an overflow, even though the result would
have enough space
Every time the answer includes something like: The evaluation of an
expression (rvalue) is done independent of the type of the variable to
which it will be assigned (lvalue) .
A statement I do agree with 100%.
Therefore in "Int := Byte + Byte" the rvalue is calculated using bytes.
And therefore an overload by result is not possible as when evaluating
what to call, the type of the lvalue is unknown.
And now I am reading this mail, and unless I misunderstood something:
The result of @Instance.Method depends on the lvalue's type or the
context? (assignment vs compare).
That seems to be in direct disagreement to the above statement?
Martin
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel