DIP1000: Scoped Pointers (Discussion)

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 11 03:13:33 PDT 2016


On 8/11/2016 3:00 AM, deadalnix wrote:
> This DIP is flawed because it only handle on
> indirection level and break down for anything more than this.

It actually does two levels - the address of the pointer variable ('ref') and 
the contents of the pointer variable ('scope'). But you are essentially correct. 
This is not a general annotation system for any pointer in a non-trivial graph 
of pointers. There is no notion of 'borrowing'.

The question, however, is whether such a system is needed. The intent with this 
DIP is for people constructing such graphs to make them safe by using reference 
counted containers for the nodes rather than networks of annotated raw pointers.

This scheme is good enough to prevent the escape of addresses on the stack, and 
for containers to prevent the escape of pointers to their contents.


More information about the Digitalmars-d mailing list