[Grace-core] Layout rules for Grace

Michael Homer mwh at ecs.vuw.ac.nz
Tue Jan 31 19:11:39 PST 2012


On Wed, Feb 1, 2012 at 2:46 PM, Andrew P. Black <black at cs.pdx.edu> wrote:
> Herewith is a first cut at layout rules for Grace.
>
> Some background: We agreed last winter in London that we would require { and } instead of trying to infer them from indentation, but that indentation would be required so that programs were readable, and so that all programs have the same appearance.  This is to avoid a student who has learned Grace form one book being confused when she looks at a web page with different formatting.
>
> We also agreed to enforce this by having the compiler reject programs where the indentation was wrong.  However, we never wrote down the rules.  This is notoriously difficult.  I'm sure that what follows isn't right, but I think that it is a reasonable first cut.  As we apply these rules to Grace code, we will find examples where they don't work, and then — and only then — we will embellish the rules.
> • A multi-part method name shall be written either
>        (1) all on one line, or
>        (2) with all parts of the name at the same indentation.
>
> Example:
>
>   while { … } do {…}
>
> or
>
>   while {…}
>   do {…}
I don't think this can parse. That is two separate calls, one to
"while" and one to "do".
-Michael


More information about the Grace-core mailing list