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

rikki cattermole rikki at cattermole.co.nz
Mon Nov 8 22:54:27 UTC 2021


On 09/11/2021 11:40 AM, 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.

I disagree with it as being the most important (empowering scope, value 
no runtime exceptions are at the top).

However I have thought about this quite a bit due to signatures.

In a large number of cases of alias this, its due to wanting a wrapper 
struct around another type that is being managed using i.e. reference 
counting.

So, I think what we are missing is some form of custom reference type.

A type that the compiler understands has some mutable state controlling 
lifetimes (that is optional) and to treat it as another type whose state 
is being stored on the heap some place external.

That is an observation of mine, although it would fit in well with 
const. Throw in ARC, that may solve our problems here.


More information about the Digitalmars-d mailing list