[fpc-pascal] methods of an object to create others objects

Andrew Brunner andrew.t.brunner at gmail.com
Wed Jul 7 00:09:29 CEST 2010


On Tue, Jul 6, 2010 at 5:04 PM, Graeme Geldenhuys
<graemeg.lists at gmail.com> wrote:

> I meant is as in it is safe to call MyObj.Free even if MyObj = nil. I
> answered based on the explicit question.
>
> But yes, in your example where MyObj was an instance, the code in the
> destructor could still trip you up if it caused an exception of some
> kind.
>
Whew,  Ok.  Years back Delphi (the experience I'm drawing on)
Object.Free could not be done.  Now that I know FPC does the check for
nil I probably won't be using FreeAndNil anymore.  But this raises a
large concern for me.  That is the EXTRA if statement being called for
every destruction of every object will lead to a decrease in high
scale operations where Classes were chosen instead of data structures.

I think that who ever decided to add that if statement did so at the
cost of performance for high-scale systems.  That if statement would
never be true if people coding knew what they were doing.  I would
certainly have a case for removing that if statement.



More information about the fpc-pascal mailing list