Re: Tail recursion optimisation considered possible

From: Eirik Berg Hanssen

Date: July 13, 2012 15:21

Subject: Re: Tail recursion optimisation considered possible

Message ID: CAHAeAG6734iU0HT+5L1O-Y3FGvjg7pK8q_sCoLJX_gsz+TS_+g@mail.gmail.com

July 13, 2012 15:21Re: Tail recursion optimisation considered possible

On Fri, Jul 13, 2012 at 11:39 PM, Rev. Chip <rev.chip@gmail.com> wrote: > On Fri, Jul 13, 2012 at 11:08:54AM -0700, Jan Dubois wrote: > > On Fri, 13 Jul 2012, Jan Dubois wrote: > > > On Fri, 13 Jul 2012, Aaron Crane wrote: > > > Don't we have that alternative return builtin already with: > > > > > > @_ = (...); > > > goto &foo; > > > > I just tested it, and "goto &__SUB__" doesn't work: > > But this does: "goto &{+__SUB__}". I think "goto __SUB__" ought to. > What do you know – it does: sidhekin@pinklady[00:19:50]~$ /opt/perl-blead/bin/perl5.17.2 use 5.016; use warnings; sub countdown { my $count = shift; if ($count) { say $count; sleep 1; @_ = ($count-1); goto __SUB__ } say "BOOM"; } countdown(3); __END__ 3 2 1 BOOM sidhekin@pinklady[00:19:56]~$ Nope, wasn't expecting that. But now I see it, I like it. :) Eirik



