News for hackers. Stuff that matters.
Re:Zed Shaw on C++ by eru on Friday July 16, 2010 @10:14AM (#1521193)
Why should memory management related to managing other resources. Anyway, you might be interested in The Haskell Disciplined Disciple Compiler (http://www.haskell.org/haskellwiki/DDC) which lets you statically encode resource management rules. (And of course spots garbage collection for memory.)
Re:Zed Shaw on C++ by tbrownaw on Friday July 16, 2010 @07:47PM (#1522957)
Your objects contain/use various resources, such as memory, file descriptors, mutexes, etc. The way to reclaim any of these is to destroy the object, which lets you reclaim all of them. So memory management is very much tied to other resource management, since they both involve the same thing (deciding when to destroy objects you no longer need). Unfortunately not all resources can be collected equally lazily, so memory-centric GC schemes that ignore the requirements of other resources tend to get in the way (and make you do using(){...} or try/finally to make sure your files are closed, instead of allowing for RAII).
Re:Zed Shaw on C++ by eru on Sunday July 18, 2010 @02:30PM (#1526368)
> The way to reclaim any of these is to destroy the object, which lets you reclaim all of them.

I asked why one should mix management of resources, and you answer that one should mix management of resources. But I still don't know why?

Re:Zed Shaw on C++ by tbrownaw on Monday July 19, 2010 @09:28AM (#1528553)
It's more that how the hell do you unmix them (any why would you bother, anyway)?
Re:Zed Shaw on C++ by eru on Tuesday July 20, 2010 @11:58AM (#1532421)
How to unmix: Just e.g. close your files explicitly, but let the memory of the data structures that represent your files be garbage collected normally.

For patterns of usage similar to RAII, Common Lisp uses unwind-protect. I already mentioned Disciplined Disciple Compiler that extends Haskell to give static guarantees for following certain rules for resource management.

Why would you bother: RAII only covers some cases for resource management, and most garbage collectors can take an arbitrary long time to collect an object that's no longer reachable. Which is fine for memory, because memory is fungible, but the attached resources, say mutexen, are not necessarily fungible.