Prototype of Ownership/Borrowing System for D

rikki cattermole rikki at
Wed Nov 27 10:24:57 UTC 2019

After having some time to think about the messages here and what the 
current specification document says, I have gotten a bit concerned about 
the complexity involved in having multiple states a pointer can be in.

Alternatively what I have derived from these discussions is that what is 
being described is essentially a head const reference type tied to 
lifetime (i.e. DIP25).

With a head const type, I think that we might be able to tick all the 
boxes without much iteration:

- Non-null
- Always points to valid memory
- Pointer cannot be modified _anywhere_ (this includes dynamic arrays 
appending, but not subslicing)
- Not possible to free (can't & or cast to void*)
- Tied to a point in the stack at CT with predetermined point of time 

I wrote up some code which basically acts as a proposal for it (using 
``const ref`` as syntax, but that is not important).

Am I completely bonkers to think that this might be a workable solution?

More information about the Digitalmars-d mailing list