DIP69 - Implement scope for escape proof references
Martin Nowak via Digitalmars-d
digitalmars-d at puremagic.com
Thu Dec 4 04:03:39 PST 2014
On Thursday, 4 December 2014 at 09:25:11 UTC, Walter Bright wrote:
> http://wiki.dlang.org/DIP69
>
Great stuff.
Will this be possible, it's a fairly important use-case.
scope ref T setVal(scope ref T t)
{
t.val = 12;
return t;
}
Another question, how would a reference counted pointer take
advantage of scope, i.e. avoid the increment/decrement when being
passed to a function?
One solution would be to add a function that returns a scoped
reference to the underlying value.
struct RefCounted(T)
{
scope ref T borrow() { return *p; }
}
Will it be possible to deduce, that the lifetime of that scoped
value is tied to the smart pointer?
More information about the Digitalmars-d
mailing list