Discussion Thread: DIP 1040--Copying, Moving, and Forwarding--Community Review Round 1
12345swordy
alexanderheistermann at gmail.com
Mon Mar 15 16:51:19 UTC 2021
On Monday, 15 March 2021 at 08:01:02 UTC, Walter Bright wrote:
> On 3/13/2021 11:47 AM, 12345swordy wrote:
>> On Saturday, 13 March 2021 at 03:06:35 UTC, Walter Bright
>> wrote:
>>> On 3/11/2021 10:56 AM, 12345swordy wrote:
>>>> How does it handle move constructors when a class have
>>>> struct type variable that is being alias this?
>>>
>>> #DIP1040 only applies to structs, not classes.
>>
>> That doesn't answer the question.
>
> The question doesn't make a lot of sense, as what does it have
> to do with classes?
>
>
>> How does the DIP interact with the current alias this system?
>> If I alias this a struct variable with move schematics in
>> struct/class definition called A, does A have the move
>> schematics of the struct variable? Replying "only applied to
>> structs and not classes" isn't helpful here. I am not talking
>> about defining move schematics for classes, I am talking about
>> the class inheriting the struct that has move schematics
>> defined, via alias this.
>
> Classes don't inherit structs. But I will guess at what you
> mean.
>
> We've discovered that alias this and classes produce a semantic
> quagmire that every proposed resolution just leads to worse
> weird cases. Hence:
>
> 1. I recommend NEVER using alias this in a class.
>
> 2. I'd like to make it illegal.
>
> 3. Any questions about how alias this works in a class, I refer
> to (1).
>
> DIP1040 does not apply to classes. If you have a class that has
> an alias this that refers to a struct with move semantics,
> you're going to be sorry :-/
>
> I recommend NEVER using alias this in a class.
Then save yourself from future headaches by making it straight up
illegal for classes to have alias this a struct that have move
schematics. As of now, it is currently possible to have alias
this in a class. Which is not going anywhere until someone create
a dip that deprecated it. (Which I am 100 percent in favor of btw)
-Alex
More information about the Digitalmars-d
mailing list