4 ms·
When 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 bl
by mikewarot 6y ago
When 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).