<div dir="ltr">Wow, very informative. I read somewhere that Python prevented infinite loops, but performing this in IDLE on my office Windows box proved me wrong:<br><br><font face="courier new,monospace">while 1:<br> print "Hi"<br>
<br><font face="arial,helvetica,sans-serif">Thomas Allen</font><br></font><br><div class="gmail_quote">2008/9/8 Alaric Snell-Pym <span dir="ltr"><<a href="mailto:alaric@snell-pym.org.uk">alaric@snell-pym.org.uk</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<div class="Ih2E3d"><br>
<br>
On 8 Sep 2008, at 2:23 pm, Thomas Allen wrote:<br>
<br>
> I know that Python can tell if a loop is infinite, although I'm not<br>
> sure if that behavior applies to Regex (and I can't test it -- I<br>
> couldn't write an infinite search if required...but if you provide<br>
> one, I will). What I mean is that there may be something of<br>
> interest in their source.<br>
<br>
</div>It's not infinity that's necessarily the problem; the problem is that<br>
it's possible to write a regexp that takes millions of years to<br>
decide. Which isn't infinite, but is a long time to wait for dinner.<br>
<br>
And you can't reliably tell if a loop is infinite. Any automated<br>
test, except in very restricted languages (non Turing-complete ones),<br>
can only classify loops (or any other bit of code into) these three<br>
categories:<br>
<br>
- Will loop forever<br>
- Won't loop forever (but might loop for a billion years)<br>
- Might loop forever; who knows?<br>
<br>
...and most samples will fall into the latter category, which tells<br>
you no more than you already knew ;-)<br>
<br>
What makes you say that Python can tell if a loop is infinite, out of<br>
interest? I'm sure it must be a misinterpretation of something,<br>
unless the halting problem has been solved while I wasn't looking...<br>
<br>
<a href="http://en.wikipedia.org/wiki/Halting_problem" target="_blank">http://en.wikipedia.org/wiki/Halting_problem</a><br>
<br>
"In computability theory, the halting problem is a decision problem<br>
which can be stated as follows: given a description of a program and<br>
a finite input, decide whether the program finishes running or will<br>
run forever, given that input.<br>
<br>
Alan Turing proved in 1936 that a general algorithm to solve the<br>
halting problem for all possible program-input pairs cannot exist."<br>
<br>
ABS<br>
<br>
- --<br>
Alaric Snell-Pym<br>
Work: <a href="http://www.snell-systems.co.uk/" target="_blank">http://www.snell-systems.co.uk/</a><br>
Play: <a href="http://www.snell-pym.org.uk/alaric/" target="_blank">http://www.snell-pym.org.uk/alaric/</a><br>
Blog: <a href="http://www.snell-pym.org.uk/?author=4" target="_blank">http://www.snell-pym.org.uk/?author=4</a><br>
<br>
<br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.8 (Darwin)<br>
<br>
iEYEARECAAYFAkjFMq4ACgkQRgz/WHNxCGqy4wCZAdUt2dQXBJrvWZerZ4cdO520<br>
XDIAnjWhygjTS5QnvNQ8M5aOuvoFq+Fm<br>
=hObQ<br>
-----END PGP SIGNATURE-----<br>
<div><div></div><div class="Wj3C7c"><br>
_______________________________________________<br>
textmate mailing list<br>
<a href="mailto:textmate@lists.macromates.com">textmate@lists.macromates.com</a><br>
<a href="http://lists.macromates.com/listinfo/textmate" target="_blank">http://lists.macromates.com/listinfo/textmate</a><br>
</div></div></blockquote></div><br></div>