DIP1000: Scoped Pointers (Discussion)

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 12 12:45:59 PDT 2016


On 11.08.2016 12:13, Walter Bright wrote:
> 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.

Assuming all the soundness issues are fixed, I think the general scheme 
it is not expressive enough. E.g. it does not allow lazy range 
algorithms from std.algorithm and std.range to be used on a slice of 
stack-allocated data. The selling points of a language are not real 
selling points if they are mutually exclusive.


More information about the Digitalmars-d mailing list