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

Reword explanation of 'size' types. #32906

Merged
merged 3 commits into from
Apr 19, 2016
Merged

Conversation

jocki84
Copy link
Contributor

@jocki84 jocki84 commented Apr 12, 2016

Do not reference machine 'pointers' in explanation of 'size' types.

I think the number of elements that can be directly addressed is a fundamental feature of a machine architecture in its own right. The fact that it coincides with the ‘size’ of a pointer should be viewed as an ‘implementation detail’ ;)

Do not reference machine 'pointers' in explanation of 'size' types.
and unsigned varieties. This makes for two types: `isize` and `usize`.
Rust also provides types whose particular size depends on the underlying machine
architecture. Their range is sufficient to express sizes of collections and they
are used to address items in a vector, for example. These types have ‘size’ as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the "for example" part misplaced or too much.

Simplify explanation and rephrase as per @GuillaumeGomez's suggestion.
Rust also provides types whose particular size depends on the underlying machine
architecture. Their range is sufficient to express the size of any collection, so
these types have ‘size’ as the category. They come in signed and unsigned varieties
which makes for two types: `isize` and `usize`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"makes" -> "make"

@petrochenkov
Copy link
Contributor

usize/isize are pointer-sized by definition, it's not an implementation detail, they are just inaccurately named.
See, for example, RFC 544 for the history of bikeshedding.

@GuillaumeGomez
Copy link
Member

@petrochenkov: I didn't understand that he said it was an implementation detail, on the contrary.

@jocki84
Copy link
Contributor Author

jocki84 commented Apr 12, 2016

@petrochenkov I think the reason I picked up on this when first reading the Rust book is that the introduction of integral types mentions pointers while pointers themselves have been moved (appropriately) towards the end of the chapter.

I feel that for an introductory text, the notion of the »largest size you'd want to express« (ignoring special purposes such as file-system interfaces) succinctly describes the purpose of these types, while the reference should of course state that they are defined to be pointer-sized.

Replace "make for" by the slightly more accurate "account for".
@steveklabnik
Copy link
Member

@bors: r+ rollup

thanks!

@bors
Copy link
Contributor

bors commented Apr 18, 2016

📌 Commit a548d4d has been approved by steveklabnik

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 18, 2016
…labnik

Reword explanation of 'size' types.

Do not reference machine 'pointers' in explanation of 'size' types.

I think the number of elements that can be directly addressed is a fundamental feature of a machine architecture in its own right. The fact that it coincides with the ‘size’ of a pointer should be viewed as an ‘implementation detail’ ;)
bors added a commit that referenced this pull request Apr 18, 2016
Rollup of 6 pull requests

- Successful merges: #32558, #32906, #33007, #33008, #33035, #33058
- Failed merges: #32912
@bors bors merged commit a548d4d into rust-lang:master Apr 19, 2016
@jocki84 jocki84 deleted the jocki84-book-size branch November 6, 2016 09:34
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

Successfully merging this pull request may close these issues.

5 participants