[sc34wg3] Making semicolons and newlines equivalent?

Xuân Baldauf xuan--2008.01--sc34wg3--isotopicmaps.org at baldauf.org
Wed Jan 30 17:24:57 EST 2008


The opinions regarding whether or not having semicolons seem to be quite
entrenched. That's why I'm raising a compromise proposal for getting the
risk of being rejected by both sides. ;-)

When searching for a formal language which is very successful in a
non-European culture, we can easily find Ruby. As CTM is necessarily a
formal language, we may be able to copy some syntax-features from Ruby.
One of them is the equivalence of semicolons and newlines.

This means:

    http://psi.example.org/beatles/paul
        isa person;
        has-shoesize(45);
        is-member-of(the-beatles);
        homepage <http://www.paulmccartney.com/>;
    .

is equivalent to

    http://psi.example.org/beatles/paul
        isa person
        has-shoesize(45)
        is-member-of(the-beatles)
        homepage <http://www.paulmccartney.com/>
    .

is equivalent to

    http://psi.example.org/beatles/paul;
        isa person
        has-shoesize(45)
        is-member-of(the-beatles)
        homepage <http://www.paulmccartney.com/>
    .

is equivalent to

    http://psi.example.org/beatles/paul; isa person; has-shoesize(45); is-member-of(the-beatles); homepage <http://www.paulmccartney.com/> .

is equivalent to

    http://psi.example.org/beatles/paul isa person; has-shoesize(45); is-member-of(the-beatles); homepage <http://www.paulmccartney.com/> .


So, if we have multiple statements on one line, semicolons are
mandatory, while, if they are neatly packed on one statement per line,
semicolons are not mandatory. Although I do not feel very good when
making whitespace meaningful, it may still be a better approach, because
of course, whitespace is meaningful for humans.

And actually, I find all these examples quite readable (from a Germanic
POV, though). Maybe we should allow the final dot to not need whitespace
before the dot (maybe this is already the case).



Some formal languages have peculiarities due to
semicolon-newline-equivalence, an example from
http://docs.codehaus.org/display/GroovyJSR/Optional+semicolon :

    y = a + 
    b
      

Here, the parser sees that, due to the '+', the second operand ("b") is
missing. Thus, it does not treat the newline after "y = a +" as
end-of-statement.

    y = a
    + b

Here, the parser does not see anyhting missing after the "y = a", thus
it treats "y = a" as a separate statement, while "+ b" is treated as the
next statement.


It may very well be that CTM does not have such peculiarities (or if it
does, these can be satisfactorily rectified). If this is the case,
equivalence of semicolons and newlines may be a way to go.


ciao,
Xuân.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.isotopicmaps.org/pipermail/sc34wg3/attachments/20080131/9e17c4a6/attachment.htm 


More information about the sc34wg3 mailing list