Stream: ideas

Topic: Lua Like Comment Syntax


view this post on Zulip Gregory Walker (Jan 18 2024 at 18:47):

In Lua they have a really cool syntax for comments that gives you the following benefit:

(From https://www.lua.org/pil/1.3.html)
"
A comment starts anywhere with a double hyphen (--) and runs until the end of the line. Lua also offers block comments, which start with --[[ and run until the corresponding ]]. A common trick, when we want to comment out a piece of code, is to write the following:

--[[
print(10) -- no action (comment)
--]]
Now, if we add a single hyphen to the first line, the code is in again:
---[[
print(10) --> 10
--]]
In the first example, the -- in the last line is still inside the block comment. In the second example, the sequence ---[[ does not start a block comment; so, the print is outside comments. In this case, the last line becomes an independent comment, as it starts with --.
"
Is it too late to do something like this? Or is not enough of a benefit ? Or are we all using editors that do this well enough with any comment syntax and some hotkeys? Trying to get a feel for the ideas stream.

view this post on Zulip Brendan Hansknecht (Jan 18 2024 at 19:16):

Roc uses # as the comment sigil to enable shebangs at the beginning of the file

view this post on Zulip Brendan Hansknecht (Jan 18 2024 at 19:16):

Likely we want to keep that

view this post on Zulip Brendan Hansknecht (Jan 18 2024 at 19:16):

So the question would be if we can add something like #[[ for block comments.

view this post on Zulip Gregory Walker (Jan 18 2024 at 19:46):

Brendan Hansknecht said:

Roc uses # as the comment sigil to enable shebangs at the beginning of the file

Good point, really this is about adding multiline comments, which i vaguely remember wasn't included to keep things simple, but is this on/off debug functionality enough to outweight the complexity added to the language?

view this post on Zulip Brendan Hansknecht (Jan 18 2024 at 19:58):

In my mind any editor can automatically comment out a block of code so it really shouldn't matter, but idk.

view this post on Zulip Gregory Walker (Jan 18 2024 at 20:20):

Brendan Hansknecht said:

In my mind any editor can automatically comment out a block of code so it really shouldn't matter, but idk.

Typically, but suppose you're in a headless environment working with a text editor you don't know particularly well like nano or something.

view this post on Zulip Fabian Schmalzried (Jan 18 2024 at 20:22):

I think when there are multiple ways to do comments, this will lead to arguments about which is the right one.


Last updated: Jun 16 2026 at 16:19 UTC