[Grace-core] Indentation (After Teleconference)

Michael Homer mwh at ecs.vuw.ac.nz
Mon Feb 16 19:02:18 PST 2015


On Tue, Feb 17, 2015 at 1:06 PM, Andrew P Black <black at cs.pdx.edu> wrote:
> We discussed this on Monday 16th February 2015
>
> On 16 Feb 2015, at 14:47 , Andrew P Black <black at cs.pdx.edu> wrote:
>
> Indentation Questions
>
> Q0  Do we care where closing braces go?
>
> Do they always have to align with the indentation of the line that opened
> the brace, or do we allow them anywhere?
>
>
> Our conclusion
>
> If a closing brace is on a line by itself, then it must be at the same
> indentation as the line that opened the braced-construct.
> However, if a brace is on a line with other stuff, then it can fall
> anywhere.
Note that this is a reversal of the previous decision which I think
made it into the specification somewhere (or maybe it was a paper).
> Q1 Indentation of continuation lines
>
> Suppose we have a continuation line:
>
>          (X + y).
>                   foo {
>
> where does the next line (the body of the block) go?  It has to be indented,
> because of the '{', but to the right of what?   The '(' on line 1 (because
> it's the indentation of the logical line that the block contents has to be
> to the right of)?   Or the 'f' on line 2 (because thats the line where the
> block opened?
>
> Does the first rule make
>
>          (X + yVeryLong).
>                   foo {
>                   if (b) then {
>                            ...
>                   } else {
>                            ...
>                   }
>
> legal?  I think that the above is visually confusing.  Do we want the
> student to write
>
>          (X + yVeryLong).
>                            foo {
>                   if (b) then {
>                            ...
>                   } else {
>                            ...
>                   }
>
> or
>
>
>          (X + yVeryLong).
>                   foo {
>                            if (b) then {
>                                     ...
>                            } else {
>                            ...
>                            }
>
> ?
>
>
> Answer: We prefer the second form, since it distinguishes the "continuation
> line indent" from the "new block indent".   The proposed rule is:
> When a line is been continued with one or more indented continuation lines,
> the indentation of all of the continuations must be the same, and the
> indentation of the first line that is NOT part of the continuation must be
> less.
Here is a piece of real code:
        while {accept("op")onLineOfLastOr(statementToken).andAlso
                {sym.value != "="}} do {
            opcount := opcount + 1
            ...
        }
Should that be permitted or not (ignoring whether it's encouraged for
the moment)? It is the conventional layout for most other languages,
but those also don't have any semantics attached to their layout.
Should it result in an error?
-Michael


More information about the Grace-core mailing list