So now that I've had the option of //
for a while, and getting to try it, I'm finding I'm not as happy with it as I thought I would be.
Don't get me wrong--I still hate semicolon. But in light of the recent change to make backslashes a generic escaping mechanism, using slashes for comments is making the code look... too "slashy".
Basically, as frustrating as it is to say it, I think backslashes for escaping has reopened this issue.
UPDATE: Maybe not, backslash may be the wrong choice, perhaps % is better. So possibly disregard this post, stay tuned.
In examples I look at, this keeps coming up as being a clear winner. Easy to type, you don't take your hands off the keyboard. It's clean.
After endorsing --
initially, why did I back off?
At first I felt it had to be the winning thought. But then @draegtun expressed skepticism about the fact that -
was a legal word character, and then some experiences noticing --
occurs on command lines scared me off.
But Rebol will walk on the edge of uncomfortable decisions, if it means a better overall experience. a / b
and a/ b
and a /b
and a/b
are all different. That's how things roll, even if it makes people squirm at first. It's the reality of experiencing the code in real life that shows why you'd make these odd choices. So maybe --foo
is a WORD! and -- foo
is a comment, and that's not crazy. Or maybe any word starting with more than one dash is illegal, I don't know yet...I'm just putting this back on the table.
One interesting thing that backslash opens up is that \--
would be an escaped WORD!. That feels more solid and "hearty" than '--
, you won't mistakenly think that's a comment.
MARKETING PITCH: Three Styles?
People have varying tastes in commenting styles, and it's something they are frequently passionate about. The lexically rich space of Rebol makes it tough to prescribe any one form...depending on what you're writing, certain characters will stand out more or less. So it allows for any of three popular choices from other languages:
Lisp/Assembly style: This is Rebol's classic style, supported by all versions, as well as Red.
your <code> "here" ; a semicolon comments to end of line
It's concise, takes only one character to type, and is one of the easiest keys to press on most keyboards. Semicolons aren't used anywhere else in the language (besides inside string literals), so they invoke commenting behavior at any position they are used...with or with;out spacing
.
ADA/Haskell style: This is new to [Beta/One]
.
your <code> "here" -- two dashes comment to end of line
This is a comfortable and clean notation. It addresses the frequent practice of wanting to make the slight and easy-to-miss nature of semicolon by using ;--
which was a three character combination with a somewhat "messy" look. However, hyphens are legal in identifiers in Rebol, so the convention of needing a space before the comment is enforced. (other rules...?)
C++/JavaScript style: This is new to [Beta/One]
.
your <code> "here" // double slashes comment to end of line
Rebol uses the slash character much like other languages might use a "dot", in PATH!. Hence it makes a poor character to use in names of WORD!s. That frees up //
for its semi-ubiquitous use in commenting. It has a visual cleanliness which ;;
does not. Double slashes appear in URL! literals, hence it is necessary to have a space before them to get commenting behavior.
Which one should you use? For maximum compatibility in the Rebol space, choose semicolon. But if that's not a concern, use the one you're most comfortable with.
Note also that dialects can look very different from code written to run in the evaluator, so one size may not fit all... which style you use could be dialect-specific (and even help visually cue which dialect you are in!)
Sadly, this would mean DUMP would get pushed back to ??
. But, worse things have happened. I can live with it if it means comments will be better.
I don't have a firm feeling, but I just want to put the question back on the table, now that we've got all these backslashes showing up.