Guido's intuition (was Re: typetesting, adaptation, typeclasses, ...)

Tim Hammerquist tim at vegeta.ath.cx
Mon Feb 4 10:55:41 CET 2002


dman <dsh8290 at rit.edu> graced us by uttering:
> On Sun, Feb 03, 2002 at 01:40:12AM +0000, Tim Hammerquist wrote:
[ snip ]
> I have trouble with that too.  My preference (FWIW, probably nothing) :
> 
> if ( some_condition() )
> {
>     for (i = first_i();i <= 10; i++)
>     {
>         initialize_some_stuff();
>         while ( some_other_condition() )
>         {
>              do_some_more_stuff()
>         }
>     }
> }
> 
> 
> Notice how the matching braces are horizontally aligned and at the
> same level as the line that initiates the bock?  If the braces are
> removed, and colons added it will look like python (with some
> extraneous parens).

Ah yes. BSD-style. My second choice, and preferred by one of my college
professors.

>| ...yet I have no trouble parsing
>| 
>| if ( &some_condition ) {
>|     for $i (&first_i .. 10) {
>|         &initialize_some_stuff;
>|         &do_some_more_stuff while &some_other_condition;
>|     }
>| }
> 
> This is hard for me because I can't see what the '}' goes with.
> Combine this with leaving out the braces on one-line compound
> statements, and I'll have real problems.

A habit I got out of...

ie:

    /* BAD! */
    if(expression)
        stuff();

    /* Better */
    if(expression) {
        stuff();
    }

...much easier and less error-prone to add one+ more statements to the
if() block. I like that Perl removed that particularly error-prone piece
of syntactic sugar...

Tim Hammerquist
-- 
guru, n: a computer owner who can read the manual.



More information about the Python-list mailing list