On 04/02/2018 10:42 AM, ag0aep6g wrote:
On Monday, 2 April 2018 at 14:01:22 UTC, Kagamin wrote:
On Sunday, 1 April 2018 at 14:31:24 UTC, Andrei Alexandrescu wrote:
1. For immutable objects, typechecking in the presence of successive
modifications of data (first assignment by the compiler, then
modification by the user) is very difficult if not impossible. I
don't know how to do it. The single initialization model (raw/cooked)
used currently in regular immutable constructors works reasonably
well and is robust.
Do the same as in const constructor.
The way it works in a const constructor is that `this.foo = bar;` is
considered initialization, not assignment.
Affirmative. First assignment is a call to the member's constructor. We
typecheck that reasonably well already in qualified constructors, and
it's the most promising approach for the DIP.
In a postblit function, we can't say it's initialization, because the
field already has a value that can't be ignored.
Affirmative. That's what makes it so darn difficult to typecheck. If we
don't let the compiler do the initial blitting (and instead start with
T.init), the copy ctor is typechecked exactly like the regular ctor.
Andrei