in reply to what would you like to see in perl5.12?
$obj->do { stuff(@_) }
hey, a man can dream :-)
update: ysth wanted to know what the prototype for my example was. I'll explain.
First, I'll note I posted this originally because the OP made me think of Re: Automatic Loop Counter not in perl. But that may not be clear enough.
So, anyway, one of the things I do quite a lot is pass around code blocks (or anonymous subroutines subroutine references - in perl it's all the same - as, as far as I'm concerned, it should be)
That means I do a lot of stuff like
Which just looks ugly. Especially when compared to$object->method(sub { my ($arg) = @_; # stuff });
or even@result = map { insert(@your_code_here) } @input;
Sadly, that doesn't work for methods, since method calls ignore prototypes.sub one_hundred_and_one_times(&) { my $block = shift; $block->() for (0 .. 100); } @result = one_hundred_and_one_times { more($stuff) };
In other words, I'd just like
to pass "sub { # code block }" to "$object->method()" if "method" is declared with a "&" prototype.$object->method { # code block };
updated fixed syntax in example.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: what would you like to see in perl5.12? (meth protos)
by tye (Sage) on Aug 22, 2007 at 01:43 UTC |