We used to see all kinds of analysis of what kind of C code is generated from the original CFront pre-compiler for AT&T's C++. The C programmers were obsessed. We still see the same kind of obsessions in the dotnet world for some reason, much more than we saw in the early days of Java.
In Smalltalk (yeah, I know: it's "nyah! nyah!" time again) all "control flow statements" are done by sending objects messages. This "hard coded" statement...
becomes this message send (named
for (int i = 0; i < foo.Length; i++) {}
#to:do:
which can be redefined, inherited, etc. as with any message)...
...and then we leave it to the compiler to generate efficient code most of the time, and get on with our lives.
1 to: foo length do: []
If you are worried about the efficiency of a for
loop in C#, more than the number of iterations, and more than the efficiency of the body of the loop itself, well, then might I suggest you are either worrying about the wrong thing or you are using the wrong language.
Angels dancing on heads of pins, and all that.