DIP1000: Scoped Pointers

Marc Schütz via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Fri Aug 12 04:57:03 PDT 2016


On Thursday, 11 August 2016 at 22:03:02 UTC, Walter Bright wrote:
> On 8/11/2016 6:38 AM, Sönke Ludwig wrote:
>> What would be nice to add is a behavior specification for 
>> 'scope' member
>> variables (lifetime considered equal or slightly shorter than 
>> parent object
>> lifetime). For example the `RefCountedSlice.payload` and 
>> `count` fields could be
>> annotated with 'scope' to let the compiler actually guarantee 
>> that they won't be
>> accessible in a way that conflicts with their lifetime (i.e. 
>> the 'scope' return
>> of 'opIndex' would actually be enforced).
>
> That adds a fair amount of complication I haven't worked 
> through.

It can probably be done by lowering:

     scope T* payload;

Is conceptually:

     private T* payload_;
     @property scope T* payload() scope {
         return payload_;
     }


More information about the Digitalmars-d-announce mailing list