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

Re: For 5.12: tail calls for methods

Thread Previous
From:
Abigail
Date:
January 14, 2008 06:34
Subject:
Re: For 5.12: tail calls for methods
Message ID:
20080114143414.GH25494@abigail.be
On Mon, Jan 14, 2008 at 04:14:30PM +0200, 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("

That surprises me. Considering that C<foo("bar")> is an expression, 
shouldn't it be a case of 'goto EXPR'? Adding some parens makes it work:

    perl -wE 'sub foo {"bar"}; goto (foo("baz")); exit; bar: say "Hello"'
    Hello

But maybe it's caused by the parsing thinking it's parsing "goto LABEL"
and encountering an unexpected '("baz")', throwing an error instead of
trying to reparse it as "goto EXPR".



Abigail

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About