[fpc-pascal] methods of an object to create others objects
Michael Van Canneyt
michael at freepascal.org
Tue Jul 6 14:22:36 CEST 2010
On Tue, 6 Jul 2010, Graeme Geldenhuys wrote:
> On 5 July 2010 23:17, Michael Van Canneyt wrote:
>> I would even add to this that you need to guard for exceptions:
>> // do stuff
>> A.Free; Make sure it is freed, even in case of exception.
> Wouldn't it be nice if we had a try..except..finally statement
> supported in FPC. All-in-one.
> A := TSomeClass.Create;
> // do stuff
> // handle error
> A.Free; // it is freed, even in case of exception.
> This would save such a lot of typing and indentation.
In this particular case you don't need the finally at all.
If you catch the exception, code will execute normally after the except
block. You don't need the finally then.
More information about the fpc-pascal