http://qs321.pair.com?node_id=11138374

LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

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/

update

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))))); }