[fpc-pascal] Constructors & Destructors 101

Flávio Etrusco flavio.etrusco at gmail.com
Fri Apr 3 14:25:46 CEST 2009

> C) Just out of curiosity, am wondering why FreeAndNil is global procedure
> instead of a method/destructor of TObject.   I am guessing it is
> for compatibility with Delphi which may or may not have a reason?

A method could not act the way FreeAndNil works (zeroing a local
pointer variable). It could be a static/class method, but this would
just add noise to the code.
BTW FreeAndNil can only on TObject and descendants.


More information about the fpc-pascal mailing list