To quote Nikolaus Wirth on this one: the "for" loop is
just syntactic sugar. There is no need for the different
type of loops, they are just nice to look at (i.e. you
can rewrite every loop using anoother one). That's
why Oberon (successor of Modula 2, successor of Pascal)
doesn't have a "for" statement.
The reason why "for" is handled by rewriting it to
a "while" construct: well, reuse, I guess. Since all
loops are in essence equivalent, you choose one which
is easy to implement and transform the others on the
fly. Compiler gurus, your call ;-)
Andreas
| [reply] |