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

Steven Schveighoffer schveiguy at gmail.com
Tue Nov 9 03:38:59 UTC 2021


On 11/8/21 8:04 PM, deadalnix wrote:
> On Monday, 8 November 2021 at 22:40:03 UTC, Andrei Alexandrescu wrote:
>> On 2021-11-08 17:26, rikki cattermole wrote:
>>> a reference counted struct should never be const
>>
>> So then we're toast. If that's the case we're looking at the most 
>> important challenge to the D language right now.
> 
> Not necessarily, but this is in fact the same problem as the head 
> mutable problem.
> 
> If `const RCSlice!(const T)` can convert to `RCSlice!(const T)`, which 
> it should to have the same semantic as slice.
> 
> The reference counting problem goes away if you can mutate the head.

The reference count cannot be in the head, it has to be in the block. So 
this conversion is actually unsound.

-Steve


More information about the Digitalmars-d mailing list