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

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

Thread Next
From:
Father Chrysostomos
Date:
July 25, 2010 12:45
Subject:
[PATCH] Re: [perl #75904] \$ prototype does not make a unary function
Message ID:
61D5621C-3E24-4321-8373-DDAECC2283D5@cpan.org

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:

*
\sigil
\[...]
;$
;*
;\sigil
;\[...]

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


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