On 03 Apr 2009, at 03:43, Richard Ward wrote:
C) Just out of curiosity, am wondering why FreeAndNil is global
procedure instead of a method/destructor of TObject.
If you have:
var
c: tsomeclass;
begin
c:=c.tsomeclass.create;
c.freeandnil
end;
then freeandnil would get, as first (hidden) parameter, the self
pointer. However, this self pointer is a value parameter. So it would
only contain the value of "c", not its address. Hence, there is no way
to set "c" to nil inside the freeandnil method (while setting the
instance variable to nil is the entire reason for using freeandnil).
Jonas
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal