On 6/5/07, Brad Baxter <[EMAIL PROTECTED]> wrote:
snip
Apparently, unlike with named subs, both &$anon()
and $anon->() ignore prototypes.  However, like named
subs &$anon gets the caller's @_.  But that is almost
never mentioned afaict at the places in the docs where
the &$anon style call is used.

This isn't intended to be a criticism; I just wonder if some
small number of newcomers reading the docs might
be picking up calling habits from this.
snip

Yet another reason to avoid Perl 5 prototypes (they don't survive the
sub being turned into a reference).  Happily Perl 6 fixes this

pugs> sub foo ($arg) { $arg }
undef
pugs> foo()
*** No compatible subroutine found: "&foo"
   at <interactive> line 1, column 1 - line 2, column 1
pugs> foo("arg")
"arg"
pugs> my $coderef = \&foo;
sub {Syn "block" {Var "$arg"}}
pugs> $coderef()
*** No compatible subroutine found: "$coderef"
   at <interactive> line 1, column 1 - line 2, column 1
pugs> $coderef("arg")
"arg"

Admittedly, Pugs isn't doing a good job with the error message yet,
but at least it is working the way one would expect.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to