develooper Front page | perl.perl5.porters | Postings from December 2010

Re: [perl #80628] [PATCH] __SUB__

Thread Previous | Thread Next
Paul LeoNerd Evans
December 15, 2010 08:18
Re: [perl #80628] [PATCH] __SUB__
Message ID:
On Mon, Dec 13, 2010 at 04:33:19PM +0000, Zefram wrote:
> Given that (a) there are already multiple versions of this on CPAN,
> (b) there are competing versions of the semantics, and (c) it's easy
> to implement a new version on CPAN where the existing versions don't
> provide the desired semantics, it seems to me that the right place for
> this isn't the core, it's CPAN.


First off, there's callee

Secondly, if you want it for the purpose of recursive functions, try CPS

  use CPS qw( kwhile );

     sub { my ( $knext ) = @_;


It also includes some added magic to not blow up the stack if you call
it "synchronously", it turns into a real tailcall implemented by a while
loop, so the stack doesn't get consumed. Ofcourse you can also store the
$knext closure somewhere else to invoke later.

CPS is pure-perl.

Paul "LeoNerd" Evans
ICQ# 4135350       |  Registered Linux# 179460

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About