[Grace-core] Comment proposal

Michael Homer mwh at ecs.vuw.ac.nz
Wed Feb 4 16:40:28 PST 2015


On Thu, Feb 5, 2015 at 11:58 AM, Andrew P Black
<andrew.p.black at gmail.com> wrote:
>
> On 4 Feb 2015, at 12:46 , Michael Homer <mwh at ecs.vuw.ac.nz> wrote:
>
>> In particular, if you have to understand what a "syntactic unit" is
>> and is not, it's not predictable. Novice programmers are not
>> linguists.
>
> This is a good point.   A layout rule like Fortran's (C in column 6) or a lexical rule like Algol's (; comment ... ; can appear where a ; could appear) can be applied without understanding the language structure.
As an aside here, people keep saying this, and it is not how Fortran
comments work. Column 6 is for continuation lines. It's a C in column
1 that indicates discarding the line.
      PROGRAM hello
        PRINT '(A)', 'Hello, '
C     test
     c, 'world'
        STOP
      END
`gfortran -ff2c -std=legacy -ffixed-form` gives roughly f77 behaviour,
to save anyone some time.
>
> Unfortunately,  such rules don't tell us what we need to know: where in the parse tree the comments belong.  They also don't let the programmer
> put short, partial-line comments close to the things that they wish to comment upon — which is, I believe, why modern languages use more flexible rules.
>
> I like Lex's proposal of specifying where comments can go, and what they mean.   Something like:
>
>         • at the end of a line, (but not at the end of a continuation that is continued on the following line).
>           Such comments attach to the first declaration or expression on that line.
Is this the same as "may appear where a semicolon could, and attaches
to the preceding statement or declaration", or is it "may appear at
the end of the first physical line of a continuation-line sequence,
and attaches to the whole sequence"?
-Michael



More information about the Grace-core mailing list