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

Sean Kelly sean at f4.ca
Tue Nov 21 06:08:32 PST 2006


Boris Kolar wrote:
> == 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.

A lot of this can be handled by "scope."  Though I grant that using 
objects for the rest and relying on the GC for clean-up is possibly not 
ideal for resources that must be cleaned up in a timely manner.


Sean



More information about the Digitalmars-d mailing list