[fpc-pascal] methods of an object to create others objects
Marco van de Voort
marcov at stack.nl
Tue Jul 6 18:59:28 CEST 2010
In our previous episode, Andrew Brunner said:
> >> > ?obj1.Free;
> >> > ?obj2.Free;
> >> > end;
> >> >
> >> > The objectcs are protected. But is boring... :)
> >> > Everybody codify like that, afraid if resources are not available?
> >> >
> >> Nope. If Obj2 failed to create you will have a problem with Obj2.Free.
> > Nope. That's why it is free and not destroy.
> Double Nope. You cannot access methods of a nil object. Nil.Free
> will in-it-and-of-it cause a read access violation.
1. Did you test this? And then debug it?
2. Ask yourself why don't we call .destroy directly, and what the use
of .free is over .destroy.
More information about the fpc-pascal