[fpc-pascal] Re: Fpc Access Violation if AppConfigDir doesn't exist.

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Wed Feb 13 09:58:07 CET 2013


Michael Müller wrote:

> I'm not sure if somebody else mentioned this already but I have the feeling that Giuliano thinks that he has to decide to use try-finally OR try-except but there are situations where you need both. One of the criteria is if the object is local or global since for a global object it is likely that you place the .Free (or for a global object better FreeAndNil()) into a destructor or finalization section (which means that you have to stop the program in case of an error and not continue showing just a dialog) so you'll need only the try-except if you want to catch the exception. In case of a local object you'll ALWAYS have the lines

> Obj := Class.Create;
> try
>   try
>     // do some code
>   finally
>     Obj.Free;
>   end;
> except
>   writeln('We have a problem);
>   halt the program or reraise the exception or raise a new one
> end;

I tried to make that point but I'm not sure the message reached its mark.

It's possibly unfortunate that Borland chose to use "try" for both 
constructs, rather than having distinct try-except-end and 
start-finally-end forms.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list