Cameron Simpson wrote:

Back at uni we had to implement a small language in our compilers class
and the lecturer had specified a proper generic while loop, thus:

  loop:
    suite
  while invariant
    suite
  endloop

In Python, that is spelled

while True:
  suite
  if not invariant: break
  suite

I think the keywords were better than above, but it neatly handled the
fact that the while-test must often be preceeded by some setup that
would be replicated at the loop bottom in Python and many other languages:

  setup-invariant-state
  while test-invariant
    do stuff
    setup-invariant-state

Good Python programmers do not repeat the setup code like this.
See the proper say-it-once way above.

This discussion belongs back on Python ideas, where it began and should have stayed.

tjr

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to