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

I learned C mostly on pen-and-paper exercises at my university. Lots of drawing the stack and heap.


That is ... a bit weird, since C does not assume, recommend or require that non-heap variables are implemented using a stack.

It's weird to teach a language while also ripping a hole in one of its main abstractions and assuming stuff about how that works, in my opinion.


Genuinely curious: do you know of any C implementations that do not use a stack for such cases?

It seems so prevalent that locally-scoped variables are often referred to as "stack variables" in casual conversation, but I'm curious of cases where it's not true...


I was curious about this, and I found this passage in the 2007 draft of the C standard:

> 6.5.2.2.11: Recursive function calls shall be permitted, both directly and indirectly through any chain of other functions.

This either means using stack frames, or heap-allocating activation records and tying them together with references. Second is a much rarer approach.


Didn't sparc targetted C use register windows? Cursory searching didn't clarify much for me though.


It was semantic, not necessarily a literal mapping to memory. It absolutely was a correct way of modeling and explaining how C programs can be understood to work.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: