How do I create a new file using phobos ?

Janice Caron caron800 at googlemail.com
Sun Sep 23 00:58:49 PDT 2007


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.

So in general, that means that no destructor of any class, may refer
to any member variables which are of reference type?

This kinda brings us back to red code green code again, doesn't it?
One could imagine a syntax in which any class member function which
does not refer to any reference-type variables should be flagged as
"green", and then it could be a compile error for a green function to
refer to any reference-type variables, or to call a function which is
not flagged green. So then we could enforce green-correctness as well
as const-correctness. Oh, and greenness should be transitive (NOTE: I
am /not/ really suggesting this).

I have to ask though, can non-deterministic destructors actually do
/anything/ useful? That is to say, if classes which needed to be
explicitly closed all had an explicit close() function (or scope
~this() or whatever), which was allowed to call "red" code to do
proper cleanup, what would be left for the regular destructor to do?
And conversely, if the class didn't need an explicit close(), then why
would you need a destructor anyway?

It's confusing.



More information about the Digitalmars-d mailing list