Re: Layout syntax (Hans Aberg)
13 Dec 2003 20:58:23 -0500

          From comp.compilers

Related articles
Layout syntax (2003-12-03)
Re: Layout syntax (Joachim Durchholz) (2003-12-08)
Re: Layout syntax (2003-12-13)
Re: Layout syntax (Carl Cerecke) (2003-12-13)
Re: Layout syntax (Joachim Durchholz) (2003-12-14)
Re: Layout syntax (2003-12-20)
Re: Layout syntax (Joachim Durchholz) (2003-12-21)
Re: Layout syntax (2003-12-23)
Re: Layout syntax (Joachim Durchholz) (2003-12-27)
[11 later articles]
| List of all articles for this month |

From: (Hans Aberg)
Newsgroups: comp.compilers
Date: 13 Dec 2003 20:58:23 -0500
Organization: Mathematics
References: 03-12-016 03-12-060
Keywords: syntax
Posted-Date: 13 Dec 2003 20:58:23 EST

In article 03-12-060, Joachim Durchholz
<> wrote:

>> My impression is that in math, the interpretation of formulas does not
>> depend on the indentation of new lines; or, at least, I cannot recall
>> any example where it does. There are certainly formulas with
>> two-dimensional layouts, like matrices, graphs, diagrams of category
>> theory and the like. But these do not change semantics with the
>> indentation level.
>This is probably because most mathematical objects don't have much of
>a nested structure.

Quite on the contrary, pure math has a lot of nested structures, even
though perhaps not so much in formulas. One example of a common pure
math nested structure is a proof with a substatement and proof, the
latter which in its turn may contain substatement and proof.

Axioms and theorems group onto theories, which correspond to the
modules used in computer languages.

> That's also why I think that mathematical tradition isn't a source
>of inspiration for questions in this specific area.

I write on a proof-verification system, which is the reason it is a source
of inspiration to me. :-)

>> Also, formulas that depend on the indentation levels is a common
>> hurdle for programmers; such errors are hard for humans to
>> detect. Then one has lost some of the advantages with the
>> indentation syntax.

>Any references? I don't know how indentation has been a "common hurdle"
>with "hard-to-detect errors".

The source is the Haskell and Hugs mailing lists <>,
which I followed over a couple of years.

Indentation errors are not only difficult for humans to detect, they often
generate incomprehensible compiler error messages as well. One could of
course argue this has with the compiler to do, and not the layout syntax
technique. But that was the state of the art when I followed it.

>My position about indentation is this (just to clarify from what
>perspective I'm looking):

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

Any syntactic feature that one has to spend a lot of time upon without it
ever becoming natural is probably wrong anyway.

As for the question of keeping the right indentation, I recall THINK
Pascal, whose editor made the indentation automatically. That is probably
a better solution than to link it to the language.

>The space-vs-tabs problem is essentially a tool problem; tabs were
>important years ago, but on a modern system, they create more trouble
>than they solve. (In other words, a modern editor should convert all
>tabs to spaces when storing to disk, and do a "smart indent detection
>and space-to-tab conversion" when loading from disk. This is no more
>difficult than any of the tab strategies that are already

I agree that if one should use an indentation system, then one should
probably avoid a tab-to-space conversion, or make it explicit in the file.

    Hans Aberg

Post a followup to this message

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