while (a=b()) ...

Magnus L. Hetland mlh at idt.ntnu.no
Fri May 14 09:52:16 EDT 1999


Dan Schmidt <dfan at harmonixmusic.com> writes:

> Jim Meier <fatjim at home.com> writes:
> 
> | [Dan Schmidt wrote]
> | > Your loop would look something like this:
> | >
> | >   while 1 until done:
> | >     value = getValue()
> | >     if not value: done
> | >     process(value)
> | >
> | > 'done' is not a keyword; it's basically an exception (the name of
> | > which was generated by the 'until' clause) that kicks us out of the
> | > loop.
> | 

This is identical to the "detect" structure developed by Arne Halaas
in the '70ies (and which has been discussed here at least twice
already.) The detect-version would be:

detect done:
    value = getValue()
    if not value: done
    proces(value)

(Although the structure can actually do more than that...)

For a simple implementation in Python, see

   http://www.idi.ntnu.no/~mlh/python

--

  Magnus
  Lie
  Hetland        http://arcadia.laiv.org <arcadia at laiv.org>




More information about the Python-list mailing list