embedded python - cancel "while 1: pass"
Moshe Zadka
moshez at zadka.site.co.il
Thu Jan 4 11:51:03 EST 2001
On Wed, 3 Jan 2001 13:48:29 -0500, D-Man <dsh8290 at rit.edu> wrote:
>
> Just brainstorming here:
>
> you could inspect the code for such constructs and not execute those
Ummmmmm.....so far, no one has been able to solve the halting problem:
identifying a piece of code which never ends. In fact, one of the
central results of Computer Science is that it is impossible to do so.
The proof goes as follows: suppose finishes() is a function which is
given a function and answers whether that function returns or not (assume
only functions which don't receive parameters).
Now write the following function:
def foo():
if finishes(foo):
while 1:
pass
Now, if foo finishes, then foo loops. But that means foo loops, so
finishes(foo) returns false, so foo doesn't loop. This is a contradiction,
so finishes() cannot exist.
--
Moshe Zadka <sig at zadka.site.co.il>
This is a signature anti-virus.
Please stop the spread of signature viruses!
More information about the Python-list
mailing list