bearophile <bearophileh...@lycos.com> wrote:

Simen kjaeraas:

With the exception of your first example, these require quite a lot of
plumbing in the compiler, and are thus not an alternative for D2 and,
I would say, unlikely for D3. The wrapper struct with a disabled default
constructor is close to possible in D2.

Some "plumbing" is needed even for the first half of the proposal, to correctly manage partially initialized objects, it's explained here:
http://research.microsoft.com/pubs/67461/non-null.pdf

Some partial notes of mine on the topic are here:
http://d.puremagic.com/issues/show_bug.cgi?id=4571

Now this is what I wanted to see. As D does not have C++'s initialization
lists, the problem of half-initialized fields may require flow analysis.
And yes, I remember this was discussed last time, but apparently I forgot.

I see that this problem can also be thought of in the typestate paradigm:
a class is in the 'raw' state until constructors have finished running,
and in this state the invariants of members are not guaranteed to hold.

Hmm, the more I think about it, the more I believe you are right that
typestates are Awesome™, and should be included in D3.


--
Simen

Reply via email to