DIP69 - Implement scope for escape proof references

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 12 00:38:53 PST 2014


On 12/11/2014 11:55 PM, Dicebot wrote:
> On Friday, 12 December 2014 at 07:48:21 UTC, Walter Bright wrote:
>>> I don't see how this is related. It would be perfectly ok to declare root of
>>> such tree scope if it was transitive (as long as it only controls access and
>>> does not attempt early destruction).
>>
>> Are you suggesting two kinds of scope - transitive and non-transitive?
>>
>> The more I think about it, the more ref counting is the definitive case, as
>> just about everything else can be explained in terms of how ref counting works.
>
> I don't see applicability of non-transitive scope because I don't understand the
> problem with the tree or reference counting you have mentioned - that is why I
> suggested to amend DIP to put explanation there.

Consider every pointer in a tree to be a ref counted pointer. There is no 
purpose to making scope transitive - traveling from one node to the next goes 
through the usual ref counting mechanism, and the ref counting wrapper can 
control that.

Also, consider a data structure:

A -> B
C -> B

If scope is transitive, how is C going to simultaneously access B?


More information about the Digitalmars-d mailing list