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

Re: For 5.12: tail calls for methods

Thread Previous
January 14, 2008 06:34
Re: For 5.12: tail calls for methods
Message ID:
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"'

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".


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