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

Re: RFC 0004 - defer {} syntax

Thread Previous | Thread Next
From:
David Nicol
Date:
June 22, 2021 18:16
Subject:
Re: RFC 0004 - defer {} syntax
Message ID:
CAFwScO8q_zx1jLb12yRSkOmnRH2A-+mKXpVt9j6+k59W4AnDpA@mail.gmail.com
how about some kind of way to inject coderefs into the call stack, perhaps
by using C<caller(n)> as an l-value?

   sub wibble{ caller(0) = sub  { say "This runs after Hello" } }

alternately

   sub wibble{ push caller(0), sub  { say "This runs after Hello" } }


>   sub wibble {
>>     uplevel::defer { say "This runs after Hello" }
>>   }
>>
>>   {
>>     wibble();
>>     say "Hello";
>>   }
>>
>
-- 
"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