-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Seemingly contrary statements in 3.3 #2980
Comments
Function definitions are statements; you can't say |
Thank you carols10cents that does it. A voice in the back of my head said that it was something to do with defining vs calling. I think that the function definitions not ending in a semicolon was throwing me a off bit as well. And if you look at a call to a function it is immediately followed by a semicolon, though that semicolon is the ending of a statement somewhere. Or at least that is what I believe is happening :) |
main
branch to see if this has already been fixedURL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch03-03-how-functions-work.html#function-bodies-contain-statements-and-expressions
Description of the problem:
Some clarification could be added to help differentiate the definition of functions, function bodies, function declaration, and function definitions.
The 3.3 section is describing statements vs expressions.
A description of statements says "Statements are instructions that perform some action and do not return a value."
Then below says "Statements do not return values."
But, in an apparent contradiction, it also says "Function definitions are also statements; the entire preceding example is a statement in itself." followed later by "Functions can return values to the code that calls them."
Suggested fix:
A line defining the relationship of function bodies, function declarations, and function definitions. Perhaps the removal of one of the terms if they are interchangeable. (I noticed that the description for listing 3-1 describes a "declaration" and then is followed immediately with a sentence about "definitions".)
A graphical description of all the statements and expressions and their relationships (statements can be made of expressions etc).
The text was updated successfully, but these errors were encountered: