The rap against "while True:" loops
Grant Edwards
invalid at invalid.invalid
Sun Oct 11 10:08:19 EDT 2009
On 2009-10-11, Hendrik van Rooyen <hendrik at microcorp.co.za> wrote:
>
> It is often necessary, in long running applications, to set up
> loops that you would really like to run until the end of time.
> - the equivalent of a "serve forever" construct. Then while
> True is the obvious way to spell it.
Once upon a time I was working on the software requirements
specifications for a missile launcher for the US Navy. In the
section on the system's scheduler task I wrote something like
this:
The scheduler shall consist of an infinite loop that executes
the following:
1. Call this function.
2. Call that function.
[...]
The review team (mainly from Johns Hopkins University Applied
Physics Lab) told me I couldn't put an infinite loop in the
requirements document.
I replied, "OK, when or under what circumstances do you want
the launcher to stop working?"
They said that I misunderstood their comment. I can (and
indeed must) have an infinite loop in the software. I just
can't put the phrase "infinite loop" in the document. They
explained that ship captains get to review these documents.
Ship captains all took a year of undergrad FORTRAN programming
and therefore believe that an infinite loop is a bad thing.
I changed the text to read something like this:
The secheduler shall repeatedly execute the following until
the system is powered off or reset:
1. Call this function.
2. Call that function.
[...]
Everybody was happy.
Tax dollars at work...
--
Grant
More information about the Python-list
mailing list