How do I create a new file using phobos ?

Bill Baxter dnewsgroup at billbaxter.com
Fri Sep 21 22:01:27 PDT 2007


Frits van Bommel wrote:
> 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...

Aw dangit.  Now I've got to go grep through all my code to find 
everywhere I've used a scope BufferedFile.  :-(

--bb



More information about the Digitalmars-d mailing list