Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: actual block comments #1050

Open
Silicon42 opened this issue Jan 18, 2025 · 2 comments
Open

Feature Request: actual block comments #1050

Silicon42 opened this issue Jan 18, 2025 · 2 comments

Comments

@Silicon42
Copy link

Would it be possible to add new syntax for block comments to a future version?

I've started using TOML as a configuration file in one of my own projects and am so far quite happy with its capabilities, however I have run into one friction point, the lack of a proper way to temporarily comment out a large continuous swath of the config natively. Sure I can use Notepad++ multi-line editing or whatever current IDE equivalent there is, but if an end user ever has to do that and comment out a bunch, they almost certainly won't have that luxury.

I'm not sure what would work for the syntax itself since it ideally wouldn't break backwards compatibility, that means it probably can't start with '#'. About the only thing that doesn't conflict with any existing syntax are angle brackets and parentheses so maybe something like:

<#
Maybe a block
comment?
#>

With the inclusion of the '#' to better associate the syntax with normal comments maybe?

@ChristianSi
Copy link
Contributor

I think that would be a bad idea, since it would mean that a tiny token like <# would lead to possibly large parts of a file being ignored. That in turn would certainly lead to much user frustration, with people changing or adding a key/value pair and then wondering why their change is ignored. With each commented-out line explicitly marked as such, such problems cannot occur. Hence in this case error protection is more important than convenience of editing, I'd say.

Compare programming languages like Java or C, where multi-line comments are almost always written like this:

/*
 * This is a multi-line
 * comment.
 */

So people voluntary add a comment-marking character to each line, though syntactically that would not be required. With # at the start of each comment line, we already have that for free.

Also, a built-in syntax for multi-line comments doesn't seem to be missed in languages like Python.

@Silicon42
Copy link
Author

For the use case where something is a comment and is meant to stay a comment, that's fine. However when you have whole sections of a config that need to be disabled / re-enabled quickly and easily it doesn't hold up. An end user doesn't typically have an editor with convenient multi-line editing or convert selected region to comment functionality, they typically have something like Notepad or Wordpad.

As for Python not having multi-line comments, that's one of many things I personally don't like about Python and is enough of a problem that a common solution is to just use unassigned multi-line string literals in place of multi-line comments.

I'll admit that I can kind of see the argument that a small token causing much of a file to be ignored could be unintuitive, so perhaps a longer token would be a better alternative such as in XML, as a bonus it's a commonly used comment syntax.

<!--
An XML 
multi-line
comment
-->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants