[Grace-core] Comment proposal

James Noble kjx at ecs.vuw.ac.nz
Fri Feb 6 17:23:30 PST 2015


On 7/02/2015, at 13:20 pm, Michael Homer <Michael.Homer at ecs.vuw.ac.nz> wrote:

> That depends on which rules you choose to have; they're not something that happens to you. If you choose a complex rule, yes. If you choose a simple rule like, say, statement-level comments pertaining to the next line, no. Exceptions are the problem

well mostly - we also have to deal with expectations coming over from other languages, from the interweb, from tutors & teachers of Grace.

For example - people may (supposition, I don't know if they will) expect "//" comments to be legal anywhere. 
People could look at Java or JS or C code and transliterate code and comments, and then wonder why comments "break". 

In other words, while a simple rule like "comments are permitted only where semicolons are permitted - and act like semicolons"
is easy to explain, but may be harder to understand.   There are simpler rules about where comments can go (notable "anywherE")
but that turns out to be a bit more complex about attachment. 

> There is still the double-comment issue:
>    // A comment
>    var x := 4 // Another comment

Can't we define things so this is equivalent (or attachment-equivalent) to:

>    // A comment
>    // Another comment
>    var x := 4

although the question of e.g. if we can have comments in the middle of multi-part declarations and expressions seems a bigger one to me.

self compareTo (  other ) 
           ifSmaller { -1 }           // if I'm smaller, return -1 
           ifEqual    { 0 }             // if I'm equal, return zero
           ifLarger   { 1 }             // I'm biggest!! YAY! 



another thought: if our comments are really, seriously *different* to C++/C/Java/JS's  "//" comments, perhaps we should adopt another character or character sequence?    Probably the obvious option is "#"   (although people are now used to that for partial-to-end-of-line) comments; another option could be "--"   (gulp!) 


J


More information about the Grace-core mailing list