metaeducation / ren-c

Library for embedding a Rebol interpreter into C codebases
GNU Lesser General Public License v3.0
126 stars 27 forks source link

Require space before `;` is considered a comment #1087

Closed hostilefork closed 3 years ago

hostilefork commented 3 years ago

Historically, Rebol allowed semicolons to abut directly against other tokens in order to start a comment:

rebol2>> load "a;b"
== a

This was relaxed in Ren-C for URL!, given that semicolon is a valid character in urls:

>> load "http://example.com/a;b.html"
== http://example.com/a;b.html

With char-like ISSUE!, it means there is now another type that could benefit from allowing semicolons that are not "spaced out" to merge into the token itself:

>> if #; = second "a;b" [print "Convenient."]
Convenient.

However, a policy of "sometimes merging with the token and sometimes not" seems shaky.

Given the overall theme of space significance in the lexical model, this makes the shift to where semicolons are only considered comments when they are spaced out. Token types that don't accept semicolon will now raise errors:

>> load "a;b"
** Syntax Error: invalid "word" -- "a;b"

Empirically it does not seem like the idea of such "tight" comments was very popular (and the Ren-C coding standards prescribe TWO spaces off of the code for line comments).

giuliolunati commented 3 years ago

I agree, code;comment was ugly!

IngoHohmann commented 3 years ago

Having comments to have to be spaced out is a small price to pay for the convenience in usage of url! and issue!. Spaces are significant in Rebol, so it makes sense and it makes comments stand out better.