> On May 6, 2021, at 11:39 AM, J. Gareth Moreton via fpc-devel 
> <fpc-devel@lists.freepascal.org> wrote:
> 
> In the example given:
> 
>  obj := TObject.Create;
>  defer objects.Free;
> 
> What's wrong with Pascal's existing functionality?
> 
>  obj := TObject.Create;
>  try
>    ...
>  finally
>    objects.Free;
>  end;
> 
> 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 creates.

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.

Regards,
        Ryan Joseph

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to