Re: Fwd: What to do to get new users

Hairy Pixels via fpc-pascal <[email protected]>
Newsgroups gmane.comp.compilers.free-pascal.general
Message-ID <CAGsUGt=ZJCnxbQm_HdoVB1XfQX+T_j9KKGP_k0-i_U_hXduYbQ@mail.gmail.com>
 On Jan 24, 2025 at 8:38:25 AM, Nikolay Nikolov via fpc-pascal <
[email protected]> 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

_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.