A defense for bracket-less code

Stelios Xanthakis sxanth at cs.teiath.gr
Wed Apr 26 15:22:27 EDT 2006


Edward Elliott wrote:

> Dave Hansen wrote:
> 
>>Not really.  It was mostly a lead-in to that last sentence.  Problems
>>like this couldn't happen in Python.  So it's an opportunity to get a
>>giggle at the expense of programmers using a language that gives you
>>enough rope to shoot yourself in the foot...
> 
> 
> Which can be entirely avoided by making the braces mandatory rather than
> optional.  This is one thing perl got right:
> 
> while (foo);            # parse error
> while (foo) next;       # parse error
> while (foo) { next; }   # ok
> while (foo) { }         # ok
> 
> And if you compile C++ without a lint checker, well, you're playing with
> fire. :)
> 

Since the whitespaceless frontend seems relevant here, may I add that:
bugs happen. Such "statement bugs" are very easy to detect once you
see that something's going wrong. If only all the bugs were as simple
as statement bugs! But unfortunatelly, less than 0.1% of the bugs I've
encountered so far are statement bugs :(

Also, I think that perl does that because otherwise code like

	if ($x)	$y++ if $z; else $z--;

would be even more confusing :)


Stelios



More information about the Python-list mailing list