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

Walter Bright newshound at digitalmars.com
Tue Nov 21 01:56:06 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 file reads and writes can be done atomically with the functions 
in std.file, without need for RAII.



More information about the Digitalmars-d mailing list