Skip to content

Add a section about code documentation/comments #40

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

Closed
kud1ing opened this issue Apr 30, 2014 · 5 comments
Closed

Add a section about code documentation/comments #40

kud1ing opened this issue Apr 30, 2014 · 5 comments

Comments

@kud1ing
Copy link
Contributor

kud1ing commented Apr 30, 2014

Mention:

@japaric
Copy link
Member

japaric commented May 1, 2014

Not sure we want a whole chapter on comments. (But I can be persuaded)

one-line comments //

We could introduce them properly in the "Hello World" chapter.

rustdoc-style comments/documentation

This will be covered in the rustdoc chapter (which is already in the wishlist)

block comments /* */. It seems, they can be nested

Maybe this can be part of the rustdoc chapter.

@kud1ing
Copy link
Contributor Author

kud1ing commented May 2, 2014

Not sure we want a whole chapter on comments. (But I can be persuaded)

In my opinion, sections of the "Foo by example" format should be much smaller than chapters in a tutorial or a book. This format exists because it allows to look up features when needed (either while programming Rust, or when you want to compare Rust features with your favorite programming language). Most tutorials do not have a whole "chapter" on HelloWorld, if/else, enum etc. either.

block comments /* */. It seems, they can be nested
Maybe this can be part of the rustdoc chapter.

That would be a pitty, because it is not related to rustdoc at all.

What is a better place to make people discover that Rust's comment blocks can be nested (which IMO is an awesome feature for disabling/reenabling code)?

@japaric
Copy link
Member

japaric commented May 2, 2014

Sorry for my lack of excitement about nested block comments, that's caused by the fact that have not used /* */ in any of my rust code. I do code commenting with nerdcommenter in vim, and that always inserts/removes // for me.

However, how I use comments should not impede others from learning that rust has nested block comments. So let's add a chapter on comments (I'll queue it in the wishlist right now). But, I would like to see a useful example about nesting comments (not just some /* You can /* nest */ comments! */ example), before adding such chapter to the book.

@kud1ing
Copy link
Contributor Author

kud1ing commented May 3, 2014

Well, i'm not excited either, but Rust people removed it first and then missed it and put it back.

It's useful when you want to temporarily disable disabled stuff:

foo
/*
disabled
*/
bar

will be

/*
foo
/*
disabled
*/
bar
*/

Many tools like Eclipse JDT will do this instead:

/*
foo
disabled
bar
*/

which makes it hard to re-enable the block as it was.

@japaric
Copy link
Member

japaric commented Jun 17, 2014

Closing in favor of #107 and #108

@japaric japaric closed this as completed Jun 17, 2014
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