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

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

Thread Previous | Thread Next
From:
hv
Date:
October 19, 2021 21:41
Subject:
Re: Pre-RFC: try/catch/finally and generic finally blocks
Message ID:
202110192049.19JKnlP29956@crypt.org
"Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote:
[...]
:  try {
:    ## 100 lines here
:  }
:  finally {
:    say "Oh and just do this before you go"
:  }
[...]
:  {
:    ## 100 lines here
:  }
:  finally {
:    say "Oh and just do this before you go"
:  }
:
:There was no `try` at the top, meaning the reader didn't get lulled
:into a false sense of security by thinking there's exception-catching
:going on here when there isn't. It's just a bare block, doing what bare
:blocks do.

On the other hand, there is also the possibility now that you end up
with:

{
  # couple of lines here
}
# 100 lines of comments here
finally { ... }

I think it's unwise to try to mitigate every case of "100 lines here",
it seems like a short road to madness. But if you want to avoid it in
this case, I think you'd need yet another keyword. I'm not convinced
that the language is improved by tacking an optional continuation onto
bare blocks.

Either way, I do think we should be encouraging Perl developers to write
their code so as to minimize confusion, eg by factoring away "100 lines
here".

Hugo

Thread Previous | Thread Next


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