http://www.perlmonks.org?node_id=948094


in reply to Re^2: In Need of Mentoring
in thread In Need of Mentoring

Consider the difference between a C-style for loop and iteration.
Yeah, what about it? Is one of them incorrect? I know C programs with for loops that are correct, are you implying iteration is incorrect?

Replies are listed 'Best First'.
Re^4: In Need of Mentoring
by chromatic (Archbishop) on Jan 17, 2012 at 02:03 UTC
    I know C programs with for loops that are correct...

    Me too. I also know C programs with for loops that are incorrect. A C-style for loop can do everything an iterator can do, if you're willing to program it to do so. Why do languages support iteration natively instead of making everyone write structural code by hand (or by editor) every time?

    Is one of them incorrect?

    We both know better.


    Improve your skills with Modern Perl: the free book.

      If you're implying that I've suggested to never use "iterators", you cannot be further from the truth.

      But just because iterators exists, doesn't mean C-style loop are suddenly bad. Most people discover the world is more than black and white at the age of 4; but many programmers seem not have grasped the idea the world is filled with shades of gray, and even colours.

      BTW, I know Perl programs with iterators that are incorrect.

        ... but many programmers seem not have grasped the idea the world is filled with shades of gray, and even colours.

        Well certainly. Do feel free to apply that principle while reading my posts; I certainly write them with the expectation that you're capable of applying critical thought and appreciating nuance.

        BTW, I know Perl programs with iterators that are incorrect.

        As do I. I also know C programs which use strings correctly.