Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


You 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.


Wouldn’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)


In 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).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: