2 File IO Questions (Phobos)
Zane
zane.sims at gmail.com
Sat Nov 7 04:09:06 PST 2009
Frank Benoit Wrote:
> Zane schrieb:
> > Doh! I still need help with number 2, but for number 1, all I needed
> > was to use 'writeString' instead of 'write'. Like I said, still
> > getting used to Phobos. Like I said, I still need help on the
> > destructor question (#2).
> >
> > Thanks, Zane
>
> desctructors are called in not defined order. The GC puts your class
> instance 'sw' and the File instance 'sw.file' onto the list for
> destruction. So the 'sw.file' might be destructed before 'sw' is.
> Deferencing sw.file from withing sw.~this then fails.
>
> A general rule: in a dtor, never dereference member variables.
>
> You have to rely on the File dtor, to close himself if still open.
I understand, thanks very much!
More information about the Digitalmars-d-learn
mailing list