return in loop for ?
nyamatongwe+thunder at gmail.com
Thu Nov 24 11:10:09 CET 2005
> What are the claimed advantages for a single exit point? I'd have
> thought it was pretty obvious the eight-line version you gave is far
> more likely to contain errors than Mike's three-line version, wouldn't
> you agree?
Single exit point is an ancient Dijkstraism. It was one of the
constraints that were thought to be useful in the early days of
structured programming. Having function flow always terminate at the end
of the function does make analysis simpler. It helps with, for example,
managing resource lifetimes: its easy to forget to release something
when you add a return statement.
Yes, the rule has obvious shortcomings, but OTOH if it had enabled
reasonable formal verification...
More information about the Python-list