> Hello everybody, > recently, I read the following statement in a CPAN Ratings entry: > "this package also uses wantarray (a transgression amongst interface > sensibilities)." Hi Lutz,
I've read that too and my reaction was "what a totally ridiculous claim!". And it is based on ... nil or maybe http://www.perlfoundation.org/perl5/index.cgi?pbp_module_recommendation_commentary which is a total shame because it's like saying "Let's not go to the Mars because it is already complicated to go to the Moon". If it was a a transgression amongst interface sensibilities then those sensibilities would belong to the people that have developed Perl. I believe the distinction between scalar, void and list context exists because it reflects the way we think differently in different contexts. Context differentiation is not only for core functionality. It's a pity module authors forgot that. If there was a need to "defend" context (a pillar of Perl) the simplest example would be the usage of @any_array in scalar context. Once you've learned that an array in scalar context returns the number of elements in the array you just can't think differently because it _makes_ sense even if it looks unreal. P6 is taking it further but maybe the P6 ppl have very bad API sensibilities. They certainly do but they correct, or will correct, them with time because that's how a language evolves. Look at http://search.cpan.org/~dconway/Contextual-Return- v0.2.1/lib/Contextual/Return.pm You can either say "Wow! how do I use this intelligently" or "Eeek! I will never be able to master this so it is crap". This is the same kind of silly statement as "Perl is not a real object oriented language". Give it a break. Perl is a complex language. You don't have to use all the tricks in the book at the same time but you still want to use a trick or two now and then. There are certainly examples of API's that got wild because of wantarray. But the ugliest transgression seen in modules is a crappy documentation and many more modules suffer of it. Again, Perl is a complex high level language. If it's too complicated, fuzzy, has bad APIs or doesn't fit one's way of thinking, is too slow or looks like line noise, we have been blessed (no pun intended) with many supra-efficient, controlling-freak, with laser-sculpted APIs, boring languages. People, take your pick. Cheers, Nadim.