[Pdx-pm] Apache, mod_perl, Catalyst, qx, and the ampersand
Eric Wilhelm
scratchcomputing at gmail.com
Thu Dec 21 15:54:43 PST 2006
# from Wil Cooley
# on Thursday 21 December 2006 11:29:
>The only problem that
>makes the syntactic sugar less sweet is that the block-as-anon-sub is
>limited to the first parameter, so it doesn't mix as well with OO
>because you have to use a proper anonymous-sub.
Well, prototypes don't work for method calls anyway. In the list.pm,
where I was working on map and friends in OO (to allow chaining ala
ruby), I too wanted something a bit handier that 'sub ' for passing
subrefs to methods. I realized that we could just use lambda.
use utf8;
sub λ (&) {return($_[0])}
sub foo {
my $self = shift;
my $sub = shift;
print "sub is $sub";
}
main->foo(λ{"whee"});
--Eric
--
There was something witty here, but it got lost in the mail.
More information about the Pdx-pm-list
mailing list