Recommended way to do RAII cleanly

bearophile bearophileHUGS at lycos.com
Mon Jul 12 15:09:14 PDT 2010


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


More information about the Digitalmars-d-learn mailing list