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
Define the meaning of crate #201
Conversation
| @@ -237,8 +237,8 @@ configuration format. | |||
| [TOML]: https://github.com/toml-lang/toml | |||
|
|
|||
| The first line, `[package]`, is a section heading that indicates that the | |||
| following statements are configuring a package. As we add more information to | |||
| this file, we’ll add other sections. | |||
| following statements are configuring a package, also known as a crate. As | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages and crates are different. a package is a collection of crates...
|
We do define crate in the first place that we actually say the word crate: https://github.com/rust-lang/book/blame/master/src/ch02-00-guessing-game-tutorial.md#L311 And we're changing this slightly on this unmerged PR that will be merged soon: https://github.com/rust-lang/book/pull/192/files#diff-72abe2e4f06575ae5318165fb3b3e5a5R346 @steveklabnik is the definition in the 2nd place i just linked to wrong? |
|
Ok i lied, it's not the first place we say "crate"... but we do define it eventually. Maybe we should move this text up then. |
|
To be clear, I'm all about making this more clear, it's just that it's complicated, so we kinda skirted around it because it's really complicated to get into this early in the book.
Yeah, so this definition is problematic because "package" does mean something specific in terms of Cargo, but you're using it in a general sense here. Historically speaking, a "compilation unit" is the definition we use. This comes from C and C++, which has three phases of "here's my source" to "here's something I run":
Rust doesn't have a preprocessing step in this sense, and we call out to a system linker, so So yeah, in some sense, a crate is "that pile of source code you pass the root of to Whew! Soooooooooooooooooo yeah, I don't know how to be both technically precise, yet accessible. |
|
Ok, so I've decided that instead of merging this, I'm adding the same definition of crate to the actual first place we use the word. I'm going to adjust the version that's on the PR I mentioned to say something like "Remember we said that a crate is... binary crates are.. library crates are...". But thank you for pointing this out, @elahn!! Also, thank you for that long and insightful comment @steveklabnik -- it's in the book now! |
The meaning of the term "crate" could be inferred, but stating it explicitly may lead to less confusion.