title: Why are we allowed to harass an iterating variable in a for loop
body: <p>Sorry about the question being so generic, but I've always wondered about this.</p>
  
  <p>In a for loop, why doesn't a compiler determine the number of times it has to run based on the initializer,condition and increment and then run the loop for the predetermined number of times?</p>
  
  <p>Even the advanced for in Java and the for in python which allow us to iterate over collections would act funny if we modified the collection.</p>
  
  <p>If we do want to change the iterating variable or the object we are iterating upon, we might as well use a while loop instead of a for. Are there any advantages to using a for loop in such a case?</p>
  
  <p>Since no language does a for loop the way I have described, there must be a lot of things I haven't thought about. Please point out the same.</p>