On Sun, 4 Nov 2001, Gary L. Armstrong wrote:

> I am amazed. How does someone figure out that you can do this sort of thing?
>
> chomp($value[++$i] = <STDIN>);
>
> I mean, $value[++$i]?  That really works?  Crazy.  [...]


        Well, that's mostly a C-style issue (and yes, it is crazy).  C
programmers, for some bizarre reason, are convinced that there is a
tremendous shortage of whitespace in the world, and so, rather than
contribution to the death of the Old Growth Whitespace forests, they will
go to incredible lengths to jam things onto one line.  Personally, I have
this thing for clarity.  In my not-even-marginally-humble opinion, a line
of code should do one thing and one thing only (ok, sometimes I stretch a
point and do two things, if it is efficient and idiomatic).  In
particular, I have always despised the "increment a variable inside an
array index" idiom in C. Therefore, I would have written it as:

        <STDIN>;
        chomp;
        $i++;
        $value[$i] = $_;

Some people say "Oh no! Look at that!  You took up 4 lines where only 1
was needed!  Shame on you!  Gasp, horror, collapse in revulsed
convulsions."  To which I shrug.  They always thank me later, when they
need to maintain my code.

Rant mode off.  We know return you to your regularly scheduled list.

Dave



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to