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

Comments section doesn't describe the multi-line comment syntax #693

Closed
gsauthof opened this issue May 12, 2017 · 4 comments
Closed

Comments section doesn't describe the multi-line comment syntax #693

gsauthof opened this issue May 12, 2017 · 4 comments

Comments

@gsauthof
Copy link
Contributor

The Comments Section of the 2nd edition doesn't mention the /* */ multi-line comment syntax:

http://rust-lang.github.io/book/second-edition/ch03-04-comments.html

It even states:

In Rust, comments must start with two slashes and continue until the end of the line. For comments that extend beyond a single line, you’ll need to include // on each line, like this:

And closes with:

That’s all there is to comments. They’re not particularly complicated.

But all this conflicts with the Rust reference:

https://doc.rust-lang.org/reference/comments.html

(which btw also mentions doc comments ...)

Rust seems to support multiline comments since 7 years:

rust-lang/rust#66

@steveklabnik
Copy link
Member

Yes, this is on purpose. The Book is supposed to show idiomatic Rust, and to teach you the language, not show you every last nook and cranny of the language. Multi-line comments are not considered idiomatic, and so aren't described in the book. Thanks for reporting though!

@gsauthof
Copy link
Contributor Author

Interesting.

Are there specific reasons for considering /* */ as non-idiomatic Rust?

I'm asking since /* */ style comments aren't obviously ugly nor error prone. For example, I've never heard somebody complain about them. Also, the Rust reference and grammar specify them without any word of caution.

Describing the two Rust commenting styles is far away from showing 'every last nook and cranny of the language'.

Omitting certain advanced features from an 'introductory book about Rust' is fine.

But this section does more. It lists several false statements:

'In Rust, comments must start with two slashes and continue until the end of the line.'

Wrong. Correct is: In Rust, comments may also start with /* and those continue until the next matching */.

'That’s all there is to comments.'

Wrong. Correct is: That isn't all there is to comments. There is more. There are /* */ multi-line comments. And comments with documentation semantics.

'They’re not particularly complicated.'

Wrong. Correct is: // and /* */ style comments are very simple - even more so, because they are available in so many popular languages. But doc-comments arguably can be seen as kind of complicated.

@lazarillo
Copy link

@gsauthof I am new to Rust, so I cannot speak to why multi-line is considered non-idiomatic within Rust, specifically.

However, I have noticed in the last few years, as generated documentation has become easier to implement, that there is an effort to make comments shorter and simpler. In fact, there is a mild rant against using too many comments within Python because user documentation can also be embedded within the code. I've seen similar suggestions with Javascript and creating JSDocs.

These are higher level languages, but maybe the same thing is true for a "brand new" low level language like Rust?

@ThomasR
Copy link

ThomasR commented Sep 25, 2019

The Book is supposed to show idiomatic Rust, and to teach you the language, not show you every last nook and cranny of the language.

This is not consistent with Appendix B, where the block comments show up. Does that mean the appendix should be removed from the book?

@rust-lang rust-lang locked as resolved and limited conversation to collaborators Sep 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants