DIP 1040

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Sun Jul 14 12:52:12 UTC 2024


On 14/07/2024 10:25 PM, Timon Gehr wrote:
> On 7/13/24 08:36, Richard (Rikki) Andrew Cattermole wrote:
>> On 13/07/2024 7:46 AM, Walter Bright wrote:
>>> https://github.com/dlang/DIPs/blob/master/DIPs/DIP1040.md
>>>
>>> We're going to get back on it.
>>
>> We did some reading and reviewing of it last night.
>>
>> Some observations:
>>
>> 1. It could be simplified greatly if we had type state analysis (blit 
>> init over it and be done with it).
> 
> Not sure where `.init` enters the picture.

The primary purpose is to keep the variable in a known good state.

Cleanup and reassignment can occur safely.

>> 2. Its acting in the form of an optimization, rather than trying to be 
>> 100% moves only feature.
> 
> Well, it has to be backwards-compatible, and it does enable move-only 
> types to be used more conveniently.

Right, but its only doing a move on the last transfer, optimizing the 
copy operation.

>> 3. Isolated ala Midori could be used instead, and that buys us 
>> ownership transfer for temporal safety.
> 
> I think this is orthogonal.

Depends on what it is for.

If its a way to describe transferring ownership of memory then isolated 
should work in almost all cases. Both within a function scope and 
between functions or graphs.

If it is to help optimize your code then it is a success at that.

D isn't C++, we don't blur the lines between classes and structs. What 
will fit best for us for ownership transfer won't be move constructors 
like C++ has.


More information about the Digitalmars-d mailing list