[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Philosophy of for loops



Hello, again, everyone!

I was just wondering what the general concensus of the "IDL Expert
Programmers" was on the use of for loops. When I first learned IDL, I
remember getting from someone or somewhere the mantra "for loops are evil"
because they take up so much time. Of course, as I learn more and watch
what goes on in this group, it seems like "for loops are sometimes evil"
would be a better mantra. The question then becomes, when do they become
evil?

In response to my thread on summing diagonal elements, Craig said that for
loops aren't always bad if you can do a lot at once, and his code proves
that you can have some fast loops.

So what defines a slow loop? Is it having a bunch of accesses to
sub-elements of arrays? Is it just having a bunch of statments? I suppose
I could do some tests of my own, and I have a little, but it's much more
fun to hear what you all have to say on the subject. I wouldn't have seen
any IDL-ku if I just kept my thoughts to myself!

Todd