On 21 October 2012 21:38, Chris Angelico <span dir="ltr"><<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Mon, Oct 22, 2012 at 7:19 AM, Roy Smith <<a href="mailto:roy@panix.com">roy@panix.com</a>> wrote:<br>
> Of course, the same can happen in Python. I could do:<br>
><br>
> foo = "default value"<br>
> if blah == 47:<br>
> fooo = "some other value"<br>
> print foo<br>
><br>
> No syntax error, no NameError, just the wrong thing printing.<br>
<br>
</div>Yeah, that's the worst kind of bug. No error, just wrong behaviour.<br></blockquote><div><br></div><div>Au contraire, the <i>worst</i> kind is code that is wrong that - for now - happens to work... and you have no clue why.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This kind of issue is one of the "balancing downsides" of the freedom<br>
of not requiring variable declarations. For small scripts, it's not a<br>
problem, and Python and PHP both save you the hassle of explicitly<br>
telling the language that you really do know what you're doing, and<br>
that's a Good Thing. For large modules, debugging creeps up in<br>
significance, and variable declarations are less of a cost.<br>
JaCMaScript in "use strict" mode and a good linter can catch a lot of<br>
these sorts of bugs, though it has its own weirdnesses (why does a<br>
'var' statement apply to the whole function regardless of where it<br>
is?). C-derived languages with proper block scope have a good chance<br>
of catching bugs of this nature at compile time, but at the cost of<br>
demanding code that's mainly there to satisfy the compiler ("isn't it<br>
OBVIOUS that I want this to be an integer? I'm assigning an integer to<br>
it!").<br>
<div class="im"><br>
> This does<br>
> not in any way detract from the fact that PHP is a horrible language.<br>
> Trust me, if you continue to use it, your dislike for it will only grow.<br>
> It is truly evil. Have you discovered "unexpected<br>
> T_PAAMAYIM_NEKUDOTAYIM" yet?<br>
<br>
</div>The double-double-dot-in-Hebrew token name isn't actually a bad error;<br>
the only problem is the token name itself. If it said "unexpected<br>
T_SCOPE" or something, it'd be easier to debug. Several of PHP's most<br>
annoying issues are solved in version 5.4 (array indexing a function<br>
call that returns an array now works), but there's still a huge<br>
fundamental that's unsolved: Unicode support. Python FTW there,<br>
especially now that PEP 393 means strings are as compact as possible.<br>
<br>
ChrisA<br>
<span class="HOEnZb"><font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br>