The rule with try...finally is that, outside of something completely catastrophic that destroys the program flow, is that once you enter the try part, the finally part is guaranteed to be executed no matter how you leave it.

Gareth aka. Kit

On 06/05/2021 18:53, Ryan Joseph via fpc-devel wrote:

On May 6, 2021, at 11:39 AM, J. Gareth Moreton via fpc-devel 
<> wrote:

In the example given:

  obj := TObject.Create;
  defer objects.Free;

What's wrong with Pascal's existing functionality?

  obj := TObject.Create;

If there's a concern about performance penalty, maybe the compiler can work 
something out for simple finally blocks and just copy the code to any Exit 
nodes found rather than calling the pseudo-procedure that a try...finally block 
I didn't know try..finally even worked like that. :) I thought it was just for 
exceptions but I see it captures exit also. The defer keyword is nicer on the 
eyes I would say because it don't require wrapping the entire function in a big 
block of code.

So never mind then I guess. I'll start using try..finally and see how that 
works for me.

        Ryan Joseph

fpc-devel maillist  -

This email has been checked for viruses by Avast antivirus software.

fpc-devel maillist  -

Reply via email to