Challenge: write a reference counted slice that works as much as possible like a built-in slice

deadalnix deadalnix at gmail.com
Thu Nov 11 00:35:56 UTC 2021


On Wednesday, 10 November 2021 at 20:35:57 UTC, Stanislav Blinov 
wrote:
> How is that a problem, or, more to the point, how is D breaking 
> anything here, as compared to C++?

It break the construction/destruction invariant.

> The latter effectively works by convention with its "valid, but 
> unspecified state" for stdlib moved-from objects, and it's the 
> best it can afford. We won't have that. The state is specified 
> - it's .init. Right now it's also a mere convention, but it is 
> effectively going to be set in stone with the move semantics 
> DIP. It's a huge win as it allows the language to mandate rules 
> for destructor elision, which C++ can't and won't do. I'd go so 
> far as to argue that in a future version of D, the code 
> presented above won't be calling a destructor at all.

copy and destruction elision does not require to break the 
ctor/dtor invariant. I would know, the proposal that is now on 
the table is a variation of a proposal I made almost 10 years 
ago. And the move semantic part of it is broken.


More information about the Digitalmars-d mailing list