raii

Ellery Newcomer ellery-newcomer at utulsa.edu
Sun Feb 28 13:03:09 PST 2010


On 02/28/2010 02:34 PM, sybrandy wrote:
> <snip>
>
> I have two questions for you:
>
> 1) Are class destructors not good enough? If so, why?

They might be good enough, I don't know. I thought they wouldn't be 
guaranteed to be called on scope exit, though.

>
> 2) Have you looked into static destructors? I created a logging library
> and that worked perfect for me to ensure that if I killed the program
> via Ctrl-C, it would flush the output buffer and close the file handle.

I'm not really looking at unexpected terminations

>
> Personally, I really like the use of "scope" vs. RAII. Keeping the code
> to clean up a file handle or the like right by where it's declared seems
> very sensible to me.

I like scope too. But it's still something the user has to remember.

>
> Casey



More information about the Digitalmars-d-learn mailing list