On Wed, 27 Apr 2011, Alexander Klenin wrote:

On Wed, Apr 27, 2011 at 18:46,  <[email protected]> wrote:

I mean, if one does
 FreeAndNil(MyObject);
It really doesn't matter whether the reference MyObject is set to nil before
or after the call to Free ?

Sadly, it does, although I do not think it is a good programming practice.
See my first mail in this thread ;-)


My collega explained to me what you meant (your original statement was not 
clear to me).

You're referring to cases like:

Var
  MyForm : TMyForm

destructor TMyForm.Destroy;

begin
  MyForm.Something;
end;

and then somewhere

  FreeAndNil(MyForm);

Which is simply wrong coding in the destructor.

I don't think you should provide for this. This is encouraging people to
write bad code. They should get an error, and correct their code.

Michael.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to