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:
Dan Book
Date:
October 20, 2021 00:48
Subject:
Re: Pre-RFC: try/catch/finally and generic finally blocks
Message ID:
CABMkAVUxU1Z-MJt8Z-sWQUt+JCQsT-n5chhq-8nePHTFnmFXfw@mail.gmail.com
On Tue, Oct 19, 2021 at 7:45 PM Oodler 577 via perl5-porters <
perl5-porters@perl.org> wrote:

> * hv@crypt.org <hv@crypt.org> [2021-10-19 21:49:47 +0100]:
>
> > "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"
> > :  }
>
> Replying to Hugo's comment only to honor it; but in the case of
> the bare block this seems like a NOOP unless "finally" implies a
> "wait" or waitpid for thing, but I don't know what things that
> could be other than a child process spawned by either C<fork> or
> an explict background shell command via C<system> or C<``> or
> C<qx//>, etc.
>
> LABEL:
> {
>  #  do stuff
>  # spawn a child proc
> }
> finally {
>  # do more stuff but what's
>  # the state of child process?
> }
>
> 1. when does `finally` get executed, does it wait for child pid?
> 2. does LABEL: work as expected if one does, `next LABEL;`?
>

Forking has no relevance to the concept. The difference finally makes, as
with defer, is that it runs when the associated scope is exited, even if
it's done so via an exception, loop control, etc.

-Dan

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