About some bugs

Simen kjaeraas simen.kjaras at gmail.com
Wed Jan 5 16:14:49 PST 2011


bearophile <bearophileHUGS at 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


More information about the Digitalmars-d mailing list