On Wednesday 12 May 2010 00:55:13 Lutz Gehlen wrote:
> Hello everybody,
> recently, I read the following statement in a CPAN Ratings entry:
> "this package also uses wantarray (a transgression amongst interface
> sensibilities)."
> 
> I also sometimes use wantarray and don't see anything bad about it
> if the behaviour is documented (which should also be the case
> otherwise). I wondered if the above statement reflects the general
> opinion among experienced Perl authors. If yes I would be interested
> in the reasons.
> 

Making use of wantarray is a valid way to distinguish between list and scalar 
(and void) contexts. Perl 6 and http://search.cpan.org/dist/Want/ take it a 
step further and provide other contexts. Personally, I'm not a big fan of 
clobbering the return values with a list of values (like perldoc -f split) 
does, and prefer returning an array reference. But if you like to distinguish 
between array and scalar contexts, then wantarray is naturally an option.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
"Humanity" - Parody of Modern Life - http://shlom.in/humanity

God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Reply via email to