develooper Front page | perl.perl5.porters | Postings from October 2021

Re: Pre-RFC: try/catch/finally and generic finally blocks

Thread Previous
From:
Yuki Kimoto
Date:
October 20, 2021 02:01
Subject:
Re: Pre-RFC: try/catch/finally and generic finally blocks
Message ID:
CAExogxMFnC34fRJGpi3eMUxHXSkkS+ZkXWpDTBXmP3b88g-XQA@mail.gmail.com
2021-10-20 4:07 Elvin Aslanov <rwp.primary@gmail.com> wrote:

> > I don't think we should try too hard to give these meanings, as it's
>    rather unclear what they should do. Likely those should continue to be
>    syntax errors for now, and we just focus on the bare-block and
>    try/catch cases. At least for now.
>
> I fully agree with this paragraph.
> Bare blocks and try/catch pair fit best with finally.
> Thanks.
>

Me too.

try/catch pair with finally.

  try {
    say "This happens first";
  }
  catch ($e) {
    say "Oops, a failure happened";
  }
  finally {
    say "This always happens, regardless of success or failure";
  }

And Bare block with finally

  {
    ## 100 lines here
  }
  finally {
    say "Oh and just do this before you go"
  }

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About