-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Document comment syntax in language docs #1305
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
Comments
the docs still need a lot of work. here's some immediate answers to your questions:
doc comments don't really do anything yet, as far as i know. so far they're just comments following a convention. the plan is:
|
I would also like to see nested comments supported, check out D's /+ +/ comment blocks. |
nested comments work now. code;
// comment
//// nested comment ( ͡° ͜ʖ ͡°) what we don't have is lexical constructs that span multiple lines, and that's not likely to change. each line of zig code can be tokenized out of context, and |
Thanks for the answers! I'll try to put together a short PR for the docs (assuming that would be welcome).
Gotcha, thanks -- that answers my "If not, why not?" question above, and would be a great sentence to add in the docs paragraph I am asking for. (-: (I'm guessing this is also the reason for the weird syntax for multiline strings?) |
Yes. the multiline string syntax actually does stack in the way i mentioned above, and it's used here: Lines 3279 to 3281 in 5d4a02c
For both commenting and quoting using the line-prefix syntax, you can naively apply the prefix to every line in question, and it will do what you expect. You can then remove the prefix from each line, and that will also do what you expect. This guarantee is not true with C/C++/Java/JavaScript/etc style comment syntax. Here's a code example that demonstrates just how difficult it is to get /*
string findComment(String s) {
int endIndex = find(s, "*/"), startIndex = find(s, "/*");
return s.substring(startIndex, endIndex);
}
*/ And that's not even trying to obfuscate things, like this:
In Zig, comments are really simple, and they are easy to work with as long as your text editor has a rectangular/column edit mode. |
The contents of this section come from the discussion on issue ziglang#1305.
The contents of this section come from the discussion on issue #1305.
this is really the ideal. it's long past time for all editors to support easily toggling the comment status of multiple lines, and there's no reason for a language to acquire needless complexity to solve a problem that should be solved by editors... |
Maybe this is silly of me, but the docs never seem to explain the comment syntax anywhere. Sure, the code examples make it immediately clear that
//
is the single-line comment syntax, but that still leaves me, as a new Zig programmer, with several questions:/* comment */
)? If not, why not? If so, what is the syntax, and do they nest?All that is to say, it would be nice to have a paragraph early in the docs explaining the comment syntax.
The text was updated successfully, but these errors were encountered: