Do you know where your variables are? | |
PerlMonks |
Re: Re: Re: What training do YOU need?by demerphq (Chancellor) |
on Oct 22, 2002 at 09:33 UTC ( [id://207012]=note: print w/replies, xml ) | Need Help?? |
But your choice is unfortunate. Interesting comment. Id be interested in hearing more about why you think this was an unfortunate choice. And how the C-style loop is more cumbersome but more adaptable. A C-Style for loop is always functionally and internally equivelent to a suitably constructed while loop. The primary differences being that many programmers from a C tradition find the for(;;) syntax more readable, while the rest of us find the while syntax more readble and maintainable. I am in the latter group. :-) Nine time out of ten (more really) when I see someone use a C-Style for loop they are not exploiting the equivelence to a while , but rather using a slightly less readble, more error prone and less efficient form of a for (LIST) loop. I avoid the term foreach because foreach is a synonym to for in perl, they are identical. Insofar that the majority of its use is to simulate for ($m..$n) where $m<$n I think advising people to convert to the more legible and less error prone form is probably a good idea. And I also think that its a good idea to use while () {} continue {} instead of for(;;) if only because it tends to be easier to read. Having said that in the time ive been using perl I think ive needed the construct a mere handful of times. Ultimately id argue that for(;;) is a construct mostly provided to reduce the pain for C junkies, and that in the long term better constructs that are more intuitive and less error prone are available and so should be encouraged.
--- demerphq
In Section
Meditations
|
|