develooper Front page | perl.perl5.porters | Postings from July 2010

[PATCH] Re: [perl #75904] \$ prototype does not make a unary function

Thread Next
Father Chrysostomos
July 25, 2010 12:45
[PATCH] Re: [perl #75904] \$ prototype does not make a unary function
Message ID:

On Jun 20, 2010, at 2:32 PM, Father Chrysostomos wrote:

> $ perl -le' sub foo($) { print "foo" }; foo $_, exit'
> foo
> $ perl -le' sub foo(\$) { print "foo" }; foo $_, exit'
> Too many arguments for main::foo at -e line 1, at EOF
> Execution of -e aborted due to compilation errors.
> So it looks as though the parser does not consider it unary, but op.c does.

This problem is worse than I thought. It applies to these prototypes as well:


This means that the following functions, among others, cannot be overridden by subs that parse the same way:

fileno (*)
chdir (;$)
close (;*)
dbmclose (\%)
tied (\[$@%*])
pop (;\@)

The attached patch fixes these. I hope no-one minds the space-out ‘if’ condition. I just find it *much* easier to read that way.

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