There is not much more. The context was about changing
for(;;)
to
for(@array)
or to
map {} @array
and doing it with an editor macro to the worst work
of a weak group of perlers. In a training presentation
to that group.
My points were:
-
This, in its presentation, would trivialize the issues.
-
The for(;;)
and for(LIST)
constructs are very different.
-
This a rather small issue, surely there are more
important problems in the above situation.
Your comparison of the
for(;;)
and
while
loops is a different issue. For the simple cases I
prefer a
for( $i=1; $i < 10_000_000; $i++)
as all the loop's controls are there upfront. This
assumes good practice, i.e. you don't fiddle with
$i
while looping. If you mess with
$i
then you should use a
while
loop.
You say:
Usually when someone uses
a C-Style for loop they are not exploiting the equivalence to a while , but rather using a slightly less readable, more error prone and less efficient form of a for (LIST) loop.
Which is exactly the difference I was refering to with:
more cumbersome but more adaptable.
If brevity caused my unclarity, please let
me know.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.