How do I create a new file using phobos ?
Daniel Keep
daniel.keep.lists at gmail.com
Sat Sep 22 23:10:05 PDT 2007
Janice Caron wrote:
> On 9/22/07, Bill Baxter <dnewsgroup at billbaxter.com> wrote:
>> 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.
>
> I'd vote for
>
> scope ~this()
> {
> /* for scope objects, called when the object goes out of scope */
> }
Actually, to be of *real* use, it should be called for scope objects
when they go out of scope *and* for general GC'ed objects if you
explicitly call "delete" on them. Or, perhaps:
lazy ~this()
{
// Invoked when the object is GC'ed
}
~this()
{
// Invoked when the object is deterministically destroyed somehow
}
Or, again, as Bill mentioned, there have been requests before to add this:
this(bool collected)
{
// collected is true iif the object has been GC'ed
}
-- Daniel
More information about the Digitalmars-d
mailing list