Using indentation for blocking

William Tanksley wtanksle at dolphin.openprojects.net
Fri Sep 10 21:05:24 EDT 1999


On 10 Sep 1999 23:39:08 +0200, Denys Duchier wrote:
>"Fredrik Lundh" <fredrik at pythonware.com> writes:

>>   "We will perhaps eventually be writing only small
>>   modules which are identified by name as they are
>>   used to build larger ones, so that devices like
>>   indentation, rather than delimiters, might become
>>   feasible for expressing local structure in the source
>>   language."

>>   -- Donald E. Knuth, "Structured Programming with goto
>>   Statements", Computing Surveys, Vol 6 No 4, Dec. 1974 

>While that idea is quite convenient for authoring programs manually,
>it is a nuisance for automated processing, e.g. for macros (i.e. the
>combination of textual program fragments).

I've heard that before -- but I can see absolutely no reason for that.  In
each block seperately, the block delimitations are clear; therefore,
there's no reason why a macro expansion should ever mess them up.

noWeb proves that theory completely without recourse to knowing the rules
of Python -- noWeb simply maintains indentation.

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.

>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.

>Dr. Denys Duchier			Denys.Duchier at ps.uni-sb.de

-- 
-William "Billy" Tanksley




More information about the Python-list mailing list