On Sun, 4 Jun 2006 07:09:48 +0300 Al Boldi <[EMAIL PROTECTED]> wrote:
> Flavio Etrusco wrote: > > On 6/3/06, Al Boldi wrote: > >> In the fpc-rtl there is something like this: > >> > >> procedure TObject.Free; > >> begin > >> if self<>nil then self.destroy; > >> end; > >> > >> Does this make sense? i.e. How is it possible for self to be nil? > > > > 'Self' isn't a global variable associated with the method, it's simply > > a parameter passed implicitly to the method. > > This would imply, that we are executing the class method instead of the > object method. No. The 'Self' of a class method is the class. The Self=nil test is useful for this case: var o: TObject; o:=TObject.Create; ... o.Free; o:=nil; ... o.Free; The o is given to the method as hidden parameter, accessible via Self. Mattias _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives