develooper Front page | perl.perl5.porters | Postings from January 2008

Re: For 5.12: tail calls for methods

Thread Previous | Thread Next
Michael G Schwern
January 17, 2008 09:19
Re: For 5.12: tail calls for methods
Message ID:
Yuval Kogman wrote:
> An alternative is to reuse the 'goto' keyword, as this is a syntax
> error:
> 	perl -e 'sub foo { }; goto foo("bar")' 
> 	syntax error at -e line 1, near "goto foo("

goto is already overloaded enough.  Programatically we've got three different 
meanings: one of them hard to explain (goto &NAME), another considered harmful 
(goto LABEL) and the third considered tragic (goto EXPR).

There's the social overloading of the word, "goto is bad".  And when you say 
"goto" people don't think "goto &SUB" (except maybe BASIC programmers) they 
think "goto LABEL".

I think it would be best to disassociate tail recursion from goto.  New 
keyword, please.  Alas, I have nothing better than "tail_recursion".

Why isn't Perl doing this automatically again?  Can't it see when the return 
from a subroutine call is going to be the last evaluated expression?

Robrt:   People can't win
Schwern: No, but they can riot after the game.

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