[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Re: Neat or horrid?



At 09:51 AM 5/28/00 +0300, Ariel Scolnicov wrote:
>Does it do proper tail recursion?  If not, I'd try
>
>      sub sum {@_ ? shift () + goto &sum : 0}
>
>except that it doesn't work (5.005_03).  I don't think I understand
>why not, though.

The goto & 'substitutes a call to the named subroutine for the currently 
running subroutine.'  Therefore there is no calling context to return to, 
and in this case, it marches all the way to the end until it returns 0 to 
the caller of the first sum(), not the last one.
--
Peter Scott
Pacific Systems Design Technologies


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe