DIP69 - Implement scope for escape proof references

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 11 13:41:12 PST 2014


On 12/11/2014 4:47 AM, Manu via Digitalmars-d wrote:
> On 8 December 2014 at 07:29, Walter Bright via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>> On 12/7/2014 6:12 AM, Dicebot wrote:
>>>
>>> But from existing cases it doesn't seem working good enough. For example,
>>> not
>>> being able to represent idiom of `scope ref int foo(scope ref int x) {
>>> return x;
>>> }` seems very limiting.
>>
>>
>>    scope ref int foo(ref int x);
>>
>> will do it.
>
> Will it? It looks like foo can't be called with scope data?

Yes, it can be.


> I don't have the perfect proposal, but I feel very strongly about 2 things:
> 1. It must not be a storage class; the concept was a disaster with
> ref, and I struggle with this more frequently than any other 'feature'
> in D.

I simply do not understand why distinguishing beteen ref and not-ref is a 
cornerstone of everything you do.


> 2. I feel it's a big mistake to separate it from the type system,
> which I think most agree, is D's greatest asset by far. Manipulating
> types is simple and convenient using the type system, and I think
> manipulating scope will be just as important as any other attribute as
> soon as even slightly complex use cases begin to arise.

Consider a ref counted type, RC!T. If scope were transitive, then you could not 
have, say, a tree where the edges were RC!T. I.e., the payload of an RC type 
should not be forced to be scope.



More information about the Digitalmars-d mailing list