Closed
Description
https://doc.rust-lang.org/stable/book/the-stack-and-the-heap.html includes many large tables with some connection to code, but they and the transitions between them are somewhat complicated. So one (somewhat) low-hanging fruit for improving the stack v. heap documentation would be using more colours to connect stack variables with the function they come from.
E.g. "Let’s try a three-deep example:" could look like
fn red() {
let i = 6;
}
fn blue() {
let a = 5;
let b = 100;
let c = 1;
red();
}
fn main() {
let x = 42;
blue();
}
(There's a mistake in the text: "And then red()
calls blue()
" should be "And then blue()
calls red()
".)
It would be important to just use these as an extra piece, not core to the explanation, for (colour-)blind people.
Inspired/suggested by @velartrill on twitter, who also suggests using greys in a slightly different way.