On Sat, Apr 11, 2020 at 03:19:06PM +1200, Greg Ewing wrote:

> Also it doesn't quite do a complete job, because it
> doesn't check the invariant after the last iteration,

I'm not sure whether loop invariants should be checked at the beginning 
of the loop, the end of the loop, or both. Anyone know what Eiffel does?

> and doesn't check it at all if the iterable is empty.

That is surely okay though. If the loop is never entered at all, by the 
principle of vacuous truth the condition inside the loop is true.

For what it's worth, I agree that loop invariants should look like 
assertions, not ordinary conditionals.

-- 
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/2N44ZLQILQIRLWFYRZU3QMESKWI2TXFB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to