Layout syntax (Hans Aberg)
3 Dec 2003 19:37:10 -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)
[13 later articles]
| List of all articles for this month |

From: (Hans Aberg)
Newsgroups: comp.compilers
Date: 3 Dec 2003 19:37:10 -0500
Organization: Mathematics
Keywords: syntax
Posted-Date: 03 Dec 2003 19:37:10 EST

Relating to the discussions about layout syntax in threads "Use of
punctuation in a language?" and "Significant indentation":

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.

I am writing on a proof verification language based on
metamathematics, and as a part of that I am developing a math-like
syntax (right now, up to axiomatic set theory syntax). Then I decided
to terminate formulas with a ".", instead of the traditional computer
";". Token separator is the traditional (f)lex whitespace zipout

        [ \f\r\t\v]+ {}
        \n+ {}

My conclusions based on this input is that one should for a general
syntax use a suitable punctuation, combined with a whitespace zipout
as token separator. That makes both human and computer parsing
easier. If one should depart from that formula, I tend think it should
be in grammar part localized in the general grammar, carefully
thinking over what the pros and cons are. This would correspond to the
use in math of special syntactic features when there is a great gain
in semantic expressivity.

Otherwise, a language with layout syntax, not mentioned here I think,
is Haskell <>. But then one has the problem with
equating each tab with 8 spaces, which makes correct human parsing
difficult in editors making another choice. 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.

So my conservative view is to stay away from layout syntax, unless one
is positively sure of that it has great benefits on semantic
expressivity. If one is positively sure that it has such benefits,
then one should strive to only use it in grammar localized forms.

    Hans Aberg

Post a followup to this message

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