OSNews article about C++09 degenerates into C++ vs. D discussion

Boris Kolar boris.kolar at globera.com
Tue Nov 21 01:01:58 PST 2006


== Quote from Walter Bright (newshound at digitalmars.com)'s article
> No. But most RAII usage is for managing memory, and Boris didn't say why
> he needed RAII for the stack allocated objects.

Mostly for closing OS handles, locking, caching and stuff. Like:
  getFile("a.txt").getText()

Normally, one would have to:
  1. open the file (which may allocate caching buffers, lock the file, etc.)
  2. use the file (efficiently)
  3. close the file (frees handles, buffers, releases locks, etc.)

It's a common design pattern, really.



More information about the Digitalmars-d mailing list