Comment to end-of-line with * *


#1

It’s Thanksgiving, and a good time to be thankful for “invisibles”, one of the great success stories of 2018. Their applications have gone far beyond commenting, though that’s great too:

x: 10
y: 1 comment [+ 2
z: 30] + 7

That’ll give you y = 8. Nifty.

But in the spirit of taking back attention-getting symbols like -- for epically more useful things, I’ve taken back ** from exponentiation (now just do infix exponents with pow). In an idea near-simultaneously had by @IngoHohmann and I, it now acts as “comment to end of line” (or to end of block or group, whichever comes first).

What’s the value of such a thing over //-style comments? The real power is that it clearly annotates code, and raises a visual flag of “I am not a normal source comment”

all [
    blah blah blah
    line two
    ** x: [some stuff here]
    do x
]

Had you used // it might be documentation. Maybe that line is there to illustrate a property of x, to inform the next DO line? But with ** you know it’s not an illustrative comment, it’s marked out code. It has to be LOADable, and stay LOADable. And your eye can scan up and down the page and see these things easily before committing them on accident.

If you want to use it in the middle of a line, curb its to-end-of-line-ness by putting it in a GROUP!:

any [this runs (** my-function "code that doesn't run") this runs too]

If you start a BLOCK! or GROUP! which then has newlines in it, that element will be the last thing considered…commented out to its end delimiter:

>> print "this runs" ** (
    print "this does not run"
) print "this runs too"

Getting this to work required a bit of tweaking of unfinished varargs features. But since it was done for this, now the -- form of DUMP uses it too!


Issues with "Invisibles": a truly disappearing COMMENT