Recommended way to do RAII cleanly

torhu no at spam.invalid
Mon Jul 12 15:40:24 PDT 2010


On 13.07.2010 00:09, bearophile wrote:
> Jonathan M Davis:
>>  There are lots of cases where using scope(exit) makes sense, and it's a great
>>  construct. But there are also plenty of cases where using plain old RAII with a
>>  single declaration is better. It works fine in D as long as the struct in
>>  question doesn't need a default constructor. But if it does, then it becomes a
>>  problem.
>
> Can't you use a static opCall (also suggested by Jacob Carlborg)?
>
> Bye,
> bearophile

I think that's supposed to go away, but I'm not 100% sure.  Would make 
sense, since it was added as a sort of stopgap measure when there were 
no struct literals.


More information about the Digitalmars-d-learn mailing list