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

Book: small improvement to a table to make it clearer #33743

Merged
merged 1 commit into from
May 21, 2016
Merged

Book: small improvement to a table to make it clearer #33743

merged 1 commit into from
May 21, 2016

Conversation

royalstream
Copy link
Contributor

@royalstream royalstream commented May 19, 2016

This table is used as an example of four heap values where two of them got deallocated leaving a gap.
It also has stack variables.
Instead of four stack variables I propose three, that way there's no misleading connection between the number of stack variables and heap variables.
But more importantly: three of the four stack variables had the same name (y) which could be confusing to a beginner, I changed this as well.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@steveklabnik
Copy link
Member

Hey @royalstream ;

Did you maybe miss some of the changes here? This is currently just modifying one of the entries in one of the tables, but not any of the examples or anything else. It's not super clear to me what exact changes you're proposing.

@royalstream
Copy link
Contributor Author

royalstream commented May 20, 2016

Hi,

Yes, it's a very small PR. I was going to merge this commit into my previous PR that changed several files (improved highlighting for the source code) but it had already been reviewed and approved.

Anyway, here's the rationale.

This table explains the fact that heap memory can have gaps (from deallocated values). This is the way this table was:

Address Name Value
(230) - 1 5
(230) - 2
(230) - 3
(230) - 4 42
... ... ...
3 y → (230) - 4
2 y 42
1 y 42
0 x → (230) - 1

It had four variables on the stack, three of them with the same name.
One of the y is a pointer to the heap, the other two are not. Coincidentally there are two gaps on the heap from deallocated values. A newbie could misinterpret there's a relationship between the two y not pointing to the heap and the two deallocated heap values (especially because they share the same name). The newbie could also think that's why there are exactly four stack variables and four heap variables.

This is the table with my changes (no repeated variable names, unrelated number of stack and heap variables)

Address Name Value
(230) - 1 5
(230) - 2
(230) - 3
(230) - 4 42
... ... ...
2 z → (230) - 4
1 y 42
0 x → (230) - 1

@steveklabnik
Copy link
Member

steveklabnik commented May 20, 2016

Ah, so here is part of my confusion: I thought this was in a section with a code example, so I was thinking to myself, "you can't just change the diagram without the code, what is going on?" But, embarrassingly, this is one without code, so this is super reasonable. I now see exactly what you're saying, and I agree. Thanks for your patience 😄

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented May 20, 2016

📌 Commit 519cc82 has been approved by steveklabnik

@bors
Copy link
Contributor

bors commented May 20, 2016

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented May 20, 2016

📌 Commit 519cc82 has been approved by steveklabnik

Manishearth added a commit to Manishearth/rust that referenced this pull request May 21, 2016
…r=steveklabnik

Book: small improvement to a table to make it clearer

This table is used as an example of four heap values where two of them got deallocated leaving a gap.
It also has stack variables.
Instead of four stack variables I propose three, that way there's no misleading connection between the number of stack variables and heap variables.
But more importantly: three of the four stack variables had the same name (**y**) which could be confusing to a beginner, I changed this as well.
bors added a commit that referenced this pull request May 21, 2016
Rollup of 7 pull requests

- Successful merges: #33578, #33679, #33743, #33746, #33747, #33750, #33757
- Failed merges:
@bors bors merged commit 519cc82 into rust-lang:master May 21, 2016
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.

4 participants