Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^2: Shift versus Sanity

by tadman (Prior)
on Apr 24, 2002 at 02:03 UTC ( #161500=note: print w/replies, xml ) Need Help??

in reply to Re: Shift versus Sanity
in thread Shift versus Sanity

This is one of those examples of things that bothers people, myself included. Three shifts, and no use of @_ to justify it, really. Instead, you could just declare them in a single my and be done with it, like:
my ($obj, $usr_log_file, $params) = @_;
Extra params passed by the user are discarded, as one would expect.

The reason being shifty is annoying is because it can degenerate into nonsensical situations like this:
sub foo { my $self = shift; my $foo = shift; $self->something($foo, "bar", shift, "shift", "foo"); my ($flob,$blarg,$kvetch) = (shift,shift); if ($kvetch = $flob->fnordicate($blarg)) { shift()->refnordicate($kvetch); } }
What, exactly, are the parameters to this function? You have to read and understand the entire function before it becomes clear. If this were much larger, that could be very frustrating. Unfortunately, this fictional example is not too far fetched.

Replies are listed 'Best First'.
Re: Re^2: Shift versus Sanity
by Anonymous Monk on Apr 24, 2002 at 17:50 UTC
    "shift() doesn't confuse people. People confuse people."

    I agree that the example given would be nonsensical. However, if I saw it, I wouldn't blame shift(). I'd blame the programmer who abused it in that way.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://161500]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2022-05-26 18:27 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (93 votes). Check out past polls.