logoalt Hacker News

gethlylast Thursday at 2:40 PM1 replyview on HN

> In C, you can't assign a value in a local function and then return it

I am so glad I never taken up C. This sound like a nightmare of a DX to me.


Replies

kjeetgilllast Thursday at 2:47 PM

Depending on what your working on, it's actually super nice to know very clearly what lives on the stack vs the heap for performance and compactness reasons. Basically anything that didn't come from malloc or a function calling malloc lives on the stack and doesn't live past the function it was allocated in.

And these days, if you're bothering with C you probably care about these things. Accidentally promoting from the stack to the heap would be annoying.