[fpc-pascal] Fwd: What to do to get new users

Hairy Pixels genericptr at gmail.com
Fri Jan 24 03:04:09 CET 2025


 On Jan 24, 2025 at 8:38:25 AM, Nikolay Nikolov via fpc-pascal <
fpc-pascal at lists.freepascal.org> wrote:

> Maybe because there's a much better way to write it:
>
> procedure foo();
> var
>   s1: TStringList = nil;
>   s2: TStringList = nil;
>   s3: TStringList = nil;
> begin
>   try
>     s1:=TStringList.create;
>     s2:=TStringList.create;
>     s3:=TStringList.create;
>     doWhatever(s1,s2,s3);
>   finally
>     FreeAndNil(s3);
>     FreeAndNil(s2);
>     FreeAndNil(s1);
>   end;
> end;
>
> Best regards,
>
> Nikolay


I’ve basically never used try..finally in  my own code but I have seen
really ugly nested like about in other projects. This a down stream
consequence of exceptions right?

Regards,
    Ryan Joseph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20250123/539dae42/attachment.htm>


More information about the fpc-pascal mailing list