I was expecting that a prototype sub foo(&) will parse foo {$x} with precedence foo(sub {$x}) but ...
use strict; use warnings; sub foo (&){ } sub bar {} my ($Q,$t) = (10,2); bar ($Q) + bar ($t); foo {$Q} + foo {$t}; # line 12
C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/sym.pl Too many arguments for main::foo at d:/tmp/pm/sym.pl line 12, near "}; +" Execution of d:/tmp/pm/sym.pl aborted due to compilation errors.
what is happening here?
Is that a bug or a feature?
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
update: s/d/foo/
that's unfortunate, prototypes don't seem to influence precedence at all ... :/
use strict; use warnings; sub bla($) {shift} my ($Q,$t,$res) = (10,2); sub tst { print $res= bla $Q / bla $t; } use B::Deparse; print B::Deparse->new('-p')->coderef2text(\&tst);
C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/sym.pl { use warnings; use strict; print(($res = bla(($Q / bla($t))))); }
In reply to (SOLVED) parsing problems with prototype blocks (precedence) by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |