NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Always use shift? (Score:2)
Curiously, Ben Tilly mentioned that at least one company would ding you on a code review for using shift [perlmonks.org].
Don't you think that you've just found a special case? Unless I misunderstood you, you would dislike the following:
my ($self,$user,$pass,$action) = @_;
For the that example, it seems clearer to use @_ rather than shift four times. It's clean and concise, though one might argue about the interface.
my ($class, @args) = @_;
How would you recommend using shift for that? It
Re:Always use shift? (Score:2)
Most things I write lately uses named params anyways. So there is only 1 or 2 shifts (2 if it is an object, for $self and the args). This is simply more scalable and maintainable (in my opinion).
So, I like shift and will continue to use it unless there is a compelling (or code-wise) reason not to.
Reply to This
Parent
Re:Always use shift? (Score:2)
KM wrote: Most things I write lately uses named params anyways.
Hmm... perhaps you might be the target audience for what is arguably my most useless module [cpan.org] (Sub::NamedParams).
Of course, if I ever get the courage to upload Acme::Code::Police [perlmonks.org], then that will qualify as my most useless module. I've been hesitant to do so due to potential hate mail -- not to mention lawsuits :)
Re:Always use shift? (Score:2)
I still have to upload my Acme::ReturnOne and Acme::ReturnZero to be the two most useless CPAN modules.... EVER!!