@@ -130,63 +130,64 @@ on the stack is the first one you retrieve from it.
130
130
Let’s try a three-deep example:
131
131
132
132
``` rust
133
- fn bar () {
133
+ fn italic () {
134
134
let i = 6 ;
135
135
}
136
136
137
- fn foo () {
137
+ fn bold () {
138
138
let a = 5 ;
139
139
let b = 100 ;
140
140
let c = 1 ;
141
141
142
- bar ();
142
+ italic ();
143
143
}
144
144
145
145
fn main () {
146
146
let x = 42 ;
147
147
148
- foo ();
148
+ bold ();
149
149
}
150
150
```
151
151
152
+ We have some kooky function names to make the diagrams clearer.
153
+
152
154
Okay, first, we call ` main() ` :
153
155
154
156
| Address | Name | Value |
155
157
| ---------| ------| -------|
156
158
| 0 | x | 42 |
157
159
158
- Next up, ` main() ` calls ` foo ()` :
160
+ Next up, ` main() ` calls ` bold ()` :
159
161
160
162
| Address | Name | Value |
161
163
| ---------| ------| -------|
162
- | 3 | c | 1 |
163
- | 2 | b | 100 |
164
- | 1 | a | 5 |
164
+ | ** 3 ** | ** c ** | ** 1 ** |
165
+ | ** 2 ** | ** b ** | ** 100** |
166
+ | ** 1 ** | ** a ** | ** 5 ** |
165
167
| 0 | x | 42 |
166
168
167
- And then ` foo ()` calls ` bar ()` :
169
+ And then ` bold ()` calls ` italic ()` :
168
170
169
171
| Address | Name | Value |
170
172
| ---------| ------| -------|
171
- | 4 | i | 6 |
172
- | 3 | c | 1 |
173
- | 2 | b | 100 |
174
- | 1 | a | 5 |
173
+ | * 4 * | * i * | * 6 * |
174
+ | ** 3 ** | ** c ** | ** 1 ** |
175
+ | ** 2 ** | ** b ** | ** 100** |
176
+ | ** 1 ** | ** a ** | ** 5 ** |
175
177
| 0 | x | 42 |
176
-
177
178
Whew! Our stack is growing tall.
178
179
179
- After ` bar ()` is over, its frame is deallocated, leaving just ` foo ()` and
180
+ After ` italic ()` is over, its frame is deallocated, leaving just ` bold ()` and
180
181
` main() ` :
181
182
182
183
| Address | Name | Value |
183
184
| ---------| ------| -------|
184
- | 3 | c | 1 |
185
- | 2 | b | 100 |
186
- | 1 | a | 5 |
187
- | 0 | x | 42 |
185
+ | ** 3 ** | ** c ** | ** 1 ** |
186
+ | ** 2 ** | ** b ** | ** 100** |
187
+ | ** 1 ** | ** a ** | ** 5 ** |
188
+ | 0 | x | 42 |
188
189
189
- And then ` foo ()` ends, leaving just ` main() ` :
190
+ And then ` bold ()` ends, leaving just ` main() ` :
190
191
191
192
| Address | Name | Value |
192
193
| ---------| ------| -------|
@@ -578,3 +579,4 @@ comes at the cost of either significant runtime support (e.g. in the form of a
578
579
garbage collector) or significant programmer effort (in the form of explicit
579
580
memory management calls that require verification not provided by the Rust
580
581
compiler).
582
+
0 commit comments