[Issue 9665] Structure constant members can not be initialized if have opAssign

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 10 01:53:17 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9665



--- Comment #13 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-03-10 01:53:08 PST ---
(In reply to comment #9)
> This is an insufficiency in D's design. I think we should approach this the
> same way as super() invocation and construction of qualified objects

This is close to const vs postblit problem. The problem appeared due to
unthoughtful decision to allow const objects mutation during construction. But
it is too late now.

> 3. This raw state lasts until super() has been called EXACTLY ONCE and each
> qualified field has been assigned to EXACTLY ONCE.

I am afraid such limitation would hurt programming in cases when raw object is
touched more than once.

By the way, what is about example in comment 1 when non-const opAssign stores
mutable pointer to immutable data?

> 4. At that point the object has become "cooked" and all restrictions are
> lifted.
> 
> Kenji, I recall we discussed this design in the context of const and immutable
> constructors, and you were favorable to it. How about we extend the same design
> for initializing qualified members in all contexts?
> 
> We can reuse the same primitive flow analysis that's now used for super().

I think it would be better to have special qualifier for such situation. Anyway
we implicitly have it. Problem with flow analysis is that callee may have no
idea who is caller due to separate compilation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list