[fpc-pascal] Finally, exceptions and so on.

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Thu May 14 16:17:06 CEST 2015


Ewald wrote:
> On 05/14/2015 12:08 PM, Mark Morgan Lloyd wrote:
>> Is there a single place in the documentation where this sort of
>> behaviour is described and prioritised,
> 
> Your first fragment is documented on
> http://www.freepascal.org/docs-html/ref/refse103.html At the bottom of
> that page: `Note that an Exit statement enclosed by a try .. finally
> block, will still execute the finally block.`

That's definitely the most useful page I've found, but the pertinent bit is

"If, however, an exception occurs, the program flow is immediatly 
transferred from the point where the excepion was raised to the first 
statement of the Finally statements. [...] and then the exception will 
be automatically re-raised."  (minor spelling mistakes in 2.6.4 17.3).

So in effect, both an exit and a raise first execute the innermost 
finally, then look for procedure end or exception block repeating as 
necessary. These are the only cases where syntax needs to be unwound in 
this way.

-- 
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