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

I took it as a "conceptual abstraction". It presented a mental model focused on the relationship between variables' lifetimes, intentionally glossing over the implementation details of any particular compiler.


If it is glossing over implementation details, why does it mention the stack? That _is_ an implementation detail.

AFAIK (I never looked at an official standard, only at drafts) the standard doesn’t mention the word “stack” at all

A C++ compiler is free to allocate environment frames for every block on the heap.


There are different tiers of abstraction. This post picked a level of granularity that the author felt would be helpful for a certain subset of readers.

Whether the "stack" is formalized or not, it's the mental model (and the vocabulary) that's most often used when working with this stuff. I don't think there's anything wrong with the fact that they focused on the forest and not the trees.


Yes, there are different tiers of abstraction, but I think this article, about lifetimes, would be better if it just discussed scope.

As is, it goes into implementation details for block scoped storage, but just posits that new and delete exist without mentioning any detail. That’s unbalanced.

Rereading it, it also assumes you know C well enough to know about malloc, so maybe, just saying “C++ can automatically do stuff when variables go out of scope or when you allocate or free memory. Here’s what it can do…” might be sufficient)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: