$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.
In reply to Re: what would you like to see in perl5.12?
by Joost
in thread what would you like to see in perl5.12?
by ysth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |