Hola... This message is not about removing wantarray, but finding a better solution for a typical but annoying usage-idiom.
sub value_added { # not really a wrapper my $result = original(@args); ... return $result; } Is a typically broken subroutine in perl 5, unless original() never returns lists. Usually people use wantarray, or if they're being even more politically correct, they use Want, but this is an annoying overhead. What are perl6's solutions towards making this easier? I tend to design around this, normally returning lists, unless the sub name implies singularity. Here are some ideas: # i don't like this one, it complicates things sub value_added { original(@args); # return is collected here } after { # but just before leaving, this is done: ... # how do we access the return? what can you do here? } # this seems nicer, but very ad-hoc sub value_added { return_later(original(@argS); ... # with no explicit return or return later, the return_later is # returned, instead of the last expression's result } # this is my favourite sub value_added { $return is context_sensitive = original(@args); # hides wantarray magic ... # you can ask $return what it's context is # but it pretends to be just a normal value anyway (array ref in # list, etc). How do you modify it, without breaking it? # implicit strong type? $return; # magically unwraps } # or in perl5, maybe it could be done like: sub value_added { my $return = Returner::Smart->new(sub { original(@args) }); # Returner is an object that does Want based lookups ... $returner->return; # could this do lvalue crap? } -- () Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418 perl hacker & /\ kung foo master: /me does a karate-chop-flip: neeyah!!!!!!!!!!!!!!
pgpi8tV5KTNDl.pgp
Description: PGP signature