Re: Layout syntax

Carl Cerecke <cdc@maxnet.co.nz>
13 Dec 2003 21:00:17 -0500

          From comp.compilers

Related articles
Layout syntax haberg@matematik.su.se (2003-12-03)
Re: Layout syntax joachim.durchholz@web.de (Joachim Durchholz) (2003-12-08)
Re: Layout syntax haberg@matematik.su.se (2003-12-13)
Re: Layout syntax cdc@maxnet.co.nz (Carl Cerecke) (2003-12-13)
Re: Layout syntax joachim.durchholz@web.de (Joachim Durchholz) (2003-12-14)
Re: Layout syntax haberg@matematik.su.se (2003-12-20)
Re: Layout syntax joachim.durchholz@web.de (Joachim Durchholz) (2003-12-21)
Re: Layout syntax haberg@matematik.su.se (2003-12-23)
Re: Layout syntax joachim.durchholz@web.de (Joachim Durchholz) (2003-12-27)
Re: Layout syntax haberg@matematik.su.se (2004-01-02)
[10 later articles]
| List of all articles for this month |
From: Carl Cerecke <cdc@maxnet.co.nz>
Newsgroups: comp.compilers
Date: 13 Dec 2003 21:00:17 -0500
Organization: TelstraClear
References: 03-12-016 03-12-060
Keywords: syntax, errors
Posted-Date: 13 Dec 2003 21:00:17 EST

Joachim Durchholz wrote:


> Having both indentation and structured statements is redundant. In
> other words, the indentation may be misleading about the real program
> structure, with either the indentation structure or the program
> structure being wrong. I had my share of such errors when I learned
> programming; today, I'm still spending a lot of time to keep
> indendation and program structure consistent. Using indentation right
> from the beginning would eliminate the redundancy, and spare a lot of
> time and frustration.


Let me just add to this by saying that syntax error recovery is more
difficult in a language where structure is ignored, and blocks are
explicitly delimited (by, say { and }). Consider what happens, for
example, when a closing delimiter is missing. Often a bunch of text is
parsed in the wrong context, and when an error does occur, it can be
difficult to figure out what needs to be done to recover from it.
Languages like Pascal, where procedures can be nested, are
particularly difficult. Java and C aren't quite so bad, as
methods/functions can't be nested, but the problem still arises.


In contrast, python, where the indentation *is* the structure, any
incorrect structure is immediately seen because it is directly visible
in the indentation. After all, if you are going to indent your code to
make it easy to read, you might as well use it as structure and chuck
out the block delimiters. I must admit, when I first heard indentation
was significant in python I thought "ugh!". Then I used it. It feels
odd (dangerous even!) at first, but when you get used to it, you don't
like to go back to those pointless block delimiters.


Cheers,
Carl.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.