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

Graeme Geldenhuys graemeg.lists at gmail.com
Tue Jul 6 14:13:57 CEST 2010


On 5 July 2010 23:17, Michael Van Canneyt wrote:
>
> I would even add to this that you need to guard for exceptions:
>
> A:=TSomeClass.Create;
> try
>  // do stuff
> finally
>  A.Free; Make sure it is freed, even in case of exception.
> end;


Wouldn't it be nice if we had a try..except..finally statement
supported in FPC. All-in-one.

eg:

A := TSomeClass.Create;
try
  // do stuff
except
  // handle error
finally
  A.Free; //  it is freed, even in case of exception.
end;


This would save such a lot of typing and indentation.


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list