How do I create a new file using phobos ?

Bill Baxter dnewsgroup at billbaxter.com
Sat Sep 22 12:45:14 PDT 2007


torhu wrote:
> Jarrett Billingsley wrote:
>> "Bill Baxter" <dnewsgroup at billbaxter.com> wrote in message 
>> news:fd27j5$87u$1 at digitalmars.com...
>>>
>>> Aw dangit.  Now I've got to go grep through all my code to find 
>>> everywhere I've used a scope BufferedFile.  :-(
>>>
>>
>> I'm actually very surprised that BufferedFile doesn't have a dtor 
>> which flushes and then closes its file.  File's dtor closes itself.
>>
> 
> It's a bit annoying, yeah.  I think it's because the member object might 
> already be deleted when the containing object's destructor gets called. 
>  Can't remember the exact reason for this limitation, but I think it's 
> documented somewhere.

Exactly.  The GC can't guarantee any particular order of destruction so 
members may be destroyed before their parents.
So basically BufferedFile cannot try to refer to it's File member in the 
destructor.

This is why we need some way to distinguish between deterministic 
destruction and regular gc-drived destruction as per Daniel's 
suggestion.  Another suggestion made previously was to give the dtor an 
argument that indicated whether it was a deterministic destruction or not.

--bb



More information about the Digitalmars-d mailing list