4 ms·
The first I'm hearing of the "borrow checker"... so I started reading this https://blog.logrocket.com/introducing-the-rust-borrow-checker/ https://blog.logrocke
by mikewarot 6y ago
The first I'm hearing of the "borrow checker"... so I started reading this https://blog.logrocket.com/introducing-the-rust-borrow-checker/ https://blog.logrocket.com/introducing-the-rust-borrow-check..., and I got to the part where it says
"Your programs have access to two kinds of memory where it can store values: the stack and the heap."
They left out variables, which is odd.
- coldtea 6y agoHow are variables not in either the stack or the heap?
- mikewarot 6y agoWhen you write a program, heap variables are allocated using NEW or Malloc... stack variables are local to a procedure or function, the rest are in the Var block before your code, and are neither on the heap, nor the stack. They're global to the program, or the unit.
- coldtea 6y agoYou mean global/static variables? Yeah, those are not mentioned. It also doesn't mention constant storage... That said it's not like they're the bread and butter of programming for their lack of mention to be that "odd" as the parent implies.
- Aeolun 6y agoWouldn’t that mean they’re on the heap by default? Your program will have to malloc something if they don’t go on the stack. (My low level knowledge is limited, may be completely wrong)
- coldtea 6y agoIn some (interpreted mostly) languages they are. Like some also don't have a stack at all. But in the most common languages, there is special storages for globals, statics, and constants, which is what the grandparent means (e.g. the DATA section).