3 ms·
I learned C mostly on pen-and-paper exercises at my university. Lots of drawing the stack and heap.
by whateveracct 4y ago
I learned C mostly on pen-and-paper exercises at my university. Lots of drawing the stack and heap.
- unwind 4y agoThat 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.
- turtledragonfly 4y agoGenuinely 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...
- shadowofneptune 4y agoI 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.
- dcminter 4y agoDidn't sparc targetted C use register windows? Cursory searching didn't clarify much for me though.
- whateveracct 4y agoIt 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.