Deprecating this(this)

ag0aep6g anonymous at example.com
Mon Apr 2 14:42:17 UTC 2018


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.

In a postblit function, we can't say it's initialization, because 
the field already has a value that can't be ignored.


More information about the Digitalmars-d mailing list