News for hackers. Stuff that matters.
Re:Google Go: A New Programming Language That’s Python Meets... by maw on Wednesday November 11, 2009 @12:18PM (#935577)
My main gripe with Python is that it's impossible for autoindenters to work correctly. Consider this code:

    if x == foo:
        # do things
        if y == bar:
            # do something
        # do other stuff <-- at what indent level should this line live?
    # get on with life
You and I know what that means given its indentation, but an autoindenter can't know what to do with the fifth line. It gets worse when you're moving blocks of code into different indent levels.

Now, it's true that in this simple case, you could rewrite the snippet starting with:

    if x == foo and y == bar:
        # ...
    # get on with life
but when blocks get long, this becomes less practical. And your autoindenter still doesn't know when to stop indenting and get on with life.

As a result, in my Python code, I use otherwise gratuitous pass statements all over the place–ugly, but it does the trick.

    if x == foo:
        # do things
        if y == bar:
            # do something
            pass
        # do other stuff <-- at what indent level should this line live?
        pass
    # get on with life
My hypothetical ideal language (the one that's not lispy in outward appearance, anyway) would use braces but would also not run if any inconsistencies of indentation are found.

This would be allowed:

    if x == foo {
        # stuff
        # more stuff
    }
But this would not:

    if x == foo {
        # stuff
       # more stuff <-- BAM!
    }

There are no comments on this comment yet.