How do I create a new file using phobos ?
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Fri Sep 21 15:20:21 PDT 2007
Bill Baxter wrote:
> Wait a minute, can anyone confirm that it's ok to use a scope
> BufferedFile without explicitly closing?
> BufferedFile contiains a 'new File()', but no destructor. The File's
> destructor contains a close(), however. So will the member File's
> destructor get called when the scope BufferedFile goes out of scope?
>
> It's really just a question of how scope works w.r.t classes with heap
> allocated members. Do the reference members get deleted
> deterministically on scope exit too?
No, they don't. You'd have to wait until they get GC'd. Yes, this sucks.
Putting "scope(exit) file.close;" right after your declaration should
make the case in the example behave properly...
More information about the Digitalmars-d
mailing list