You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the section above there is a diagram illustrating how the stack changes when executing the following code:
fnmain(){let n = 5;let y = plus_one(n);println!("The value of y is: {y}");}fnplus_one(x:i32) -> i32{
x + 1}
The stack is represented in 3 steps:
call to main
call to plus_one
back to main
What I find confusing is that in the second step the stack looks like this:
main
plus_one
From what I know (and also what's described in the standard version of the Rust book) the stack works similarly to pile of plates: each function call is added on top of the last one, and the one on top is the one that will get executed next.
The diagrams here seem to contradict this.
Suggested fix:
Modify the diagrams so that function calls appear on top of the previous ones
The text was updated successfully, but these errors were encountered:
This is designed to be consistent with how stacks are drawn in other areas of computer systems. For historical reasons, call stacks grow down rather than up.
URL to the section(s) of the book with this problem:
Variables live in the stack
Description of the problem:
In the section above there is a diagram illustrating how the stack changes when executing the following code:
The stack is represented in 3 steps:
main
plus_one
main
What I find confusing is that in the second step the stack looks like this:
From what I know (and also what's described in the standard version of the Rust book) the stack works similarly to pile of plates: each function call is added on top of the last one, and the one on top is the one that will get executed next.
The diagrams here seem to contradict this.
Suggested fix:
Modify the diagrams so that function calls appear on top of the previous ones
The text was updated successfully, but these errors were encountered: