Using indentation for blocking

Stephan Houben stephan at pcrm.win.tue.nl
Mon Sep 13 03:23:58 EDT 1999


On Sat, 11 Sep 1999 01:05:24 GMT, William Tanksley 
<wtanksle at dolphin.openprojects.net> wrote:
>
>A smarter system -- such as a macro system for Python itself -- would
>insert the parsed text, including the INDENT and DEDENT tokens, thus
>removing the need to keep track of indentation outside of the current text
>itself.
>

Exactly. Every non-braindead macro system (i.e. everything NOT resembling
the C pre-processor) should operate on the abstract syntax, and not
on the concrete syntax.

>>In Haskell, you can use
>>indifferently a mix of indentation or braces and semicolons to convey
>>layout structure.  This is, in my opinion, a more reasonable
>>compromise.
>
>That is indeed a compromise, and although I don't mind it at all it's not
>very much like Python -- many ways to DO something, but only one way to
>write it, and that very easy to see.

Haskell's layout system makes sense for Haskell, but far less for Python,
IMHO. The "problem" of Haskell is that the whole language is so recursive;
you can have a definition in an expression (by using a "let"-form) in
a definition in an expression... etc.That's not something a human would
typically do, but a code generator might. Even so, the code generator
could just indent every new lexical level, but that might create
massive amounts of whitespace.

Finally, Haskell is supposed to be the "standard functional language",
so it lacks the benevolant dictator who can dictate something
controversial such as using only whitespace for block structure.

Greetings,

Stephan




More information about the Python-list mailing list