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

Re: RFC 0004 - defer {} syntax

Thread Previous | Thread Next
From:
David Nicol
Date:
June 18, 2021 16:07
Subject:
Re: RFC 0004 - defer {} syntax
Message ID:
CAFwScO_QcsT0wuxGB63v2p=7defqcRnK05YSMyR2+vS6W+WivA@mail.gmail.com
so what's wrong with just squidding it out in long form?

   sub abcdefg {
       my $defer;
       ...
       my_predicate and $defer = sub {warn "MY_PREDICATE WUZ TROO!\n"};
       ...
       $defer and &$defer;
       $retval;
   }

On Fri, Jun 18, 2021 at 3:55 AM Martijn Lievaart <m@rtij.nl> wrote:

> Op 18-06-2021 om 03:16 schreef Yuki Kimoto:
> > I read the content of the Github issue again.
> >
> > defer block is like END block that runs at the end of the scope, isn't
> it?
> >
> > I feel this syntax is natural for Perl users now.
> >
> > It seems that some pseudo-things are implemented on CPAN as well.
> >
>
> Yes and no. Yes, it's like that, because it runs on the end of a scope,
> like END does at the end of the run. No, it's not like that as END
> blocks always run when compiled, but defer is a statement that must be
> executed for it to have it's effect.
>
>
> HTH,
>
> M4
>
>
>

-- 
"Lay off that whiskey, and let that cocaine be!" -- Johnny Cash

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