When I have posted that the following lines:

  Obj := Nil;
  Obj.Free();

do not raise an exception, I didn't have Delphi at
hand; but I knew that inside TObject.Free() it is
written something like this:

procedure TObject.Free();
begin
  if Self <> Nil then
    Self.Destroy;
end;

The call to Free() through Obj (that is Nil) goes OK
because:
1. Free() is not a virtual method; and as we all know,
the binding is done at compile time. That means there
is no need to access a VMT.
2. Every method of a class has a hidden parameter; and
 that parameter is Self. When calling Free, there is
no need that Obj is different then Nil as Obj (named
Self inside the method Free()) is passed as parameter.

Obj.Free() would raise an error when Obj points to a
zone of memory that is not allowed to be accessed.


      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

Reply via email to