-- Peter Scott <[EMAIL PROTECTED]>
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Abigail) writes:
On Wed, Nov 20, 2002 at 11:42:43AM +0100, Bart Lateur wrote:
On Wed, 20 Nov 2002 04:10:02 -0600, Steven Lembark wrote:
> sub commify
> {
> my ( $max, $sep, $end ) = ( shift, shift, shift );
...
> }
Wow! Hold it! Am I the only one who finds this absurd? More than one
shift on the same array in one single expressing, sounds like bad style
to me. Comments?
Why is that bad style? Many times when people say it's bad style,
it's just a case of "beauty is in the eye of the beholder".
It forces the reader to think about associativity and order of evaluation.
If you've been bitten by unexpected outcomes before you might have to
try it to make sure it does what you think.
I've used shift, shift before, so I already know. But it would be unfair
to foist on a junior maintenance programmer, IMHO.
Associativity? This just takes the first three items
off the arguments (leaving the rest of it on @_),
puts them on a list, and assigns it. I've had more
problems with junior programmers botching the order
of separate assignments (or more often deleting one
out of the middle) than mis-understanding how shift
works. Even fewer of the people walking around
understand splice (which is where I came up with the
list-of-shifts).
--
Steven Lembark 2930 W. Palmer
Workhorse Computing Chicago, IL 60647
+1 800 762 1582