Nope. Pascal and especially Modula-2, mothers of high-level languages, did calculate the bounds only once. Most others that do it the other way are probably just following the bad example of C
Indeed! I didn’t know this fact, either. But then, I never handled VB. I’m surprised that the RB docs do not point this out more clearly.
I have write access to the LR, so I’ll update the doc on for…next right now.
Jeez! That For…Next page was full of mistakes and bad examples. I have taken a full hour to work it over . Please take a look and let me know if you find any errors, unclarities or bad wording in it so that I can fix it right away:
Well I used to have edit access, but I guess I don’t any more (I can log in, but not edit). Anyway, I don’t have anything major but some minor things that I see are:
- “End” is capitalized in the for statement, but is lowercase in the table with Part and Description.
- “Statements” should be capitalized in the part/description table as well.
- You might want to add an example using a step value of -1 that is the same as the DownTo example shown at the very end, just to show that they’re the same.
Thanks for editing it!
The only other thing that I can see is that the [Exit] parameter should be [Exit [For]], as it seems as if both syntaxes will work. “Exit For” is the VB standard.
I like the revisions. One more important thing to add:
When multiple threads are running, be aware that threads may yield at every loop iteration. This can also be expensive, and if undesired, one can use #pragma BackgroundThreads to control the yielding behavior.
Alright, all requests implemented: