4 ms·
> In particular, C++ (and Rust, etc.) stresses RAII (Resource Acquisition Is Initialization) But there is no reason that the RAII pattern couldn't be completel
by amelius 11y ago
> In particular, C++ (and Rust, etc.) stresses RAII (Resource Acquisition Is Initialization)
But there is no reason that the RAII pattern couldn't be completely orthogonal to memory management.
- ExpiredLink 11y agoCould. A hypothetical new language could be created to facilitate whole-program escape analysis and thus completely avoid both GC and manual memory (resource) management.
- Others 11y agoThis sounds awfully like the ownership concepts used in Rust...
- moonchrome 11y ago>But there is no reason that the RAII pattern couldn't be completely orthogonal to memory management GC + destructors = very very messy even in languages built with GC in mind, kentonv described the whole non deterministic finalizers nicely but there are also other problems see here : http://ericlippert.com/2015/05/18/when-everything-you-know-is-wrong-part-one/ http://ericlippert.com/2015/05/18/when-everything-you-know-i...
- mlvljr 11y ago>> In particular, C++ (and Rust, etc.) stresses RAII (Resource Acquisition Is Initialization) And the new Perl, they say
- kentonv 11y agoYou could do that, but if you are using RAII, then GC has lost a lot of its value. It is incorrect to access an object after its destructor has executed, so you might as well release its heap resources then and ditch the whole complicated GC. I suppose in theory you could use GC just for objects that (transitively) don't hold any non-heap resources. But that gets a little weird as if you ever device that you need to stick a non-heap resource in there, suddenly all your code needs to change. (Of course, this is already generally the case in GC languages...)