borrowed pointers vs ref
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 13 12:17:16 PDT 2014
On 2014-05-13 19:52, Dicebot wrote:
> It has to be transitive to be useful as borrowed pointer. Consider this
> example:
>
> {
> scope A a; // has some internally managed resources
> foo(a);
> }
>
> It is not safe to destruct a in the end of the scope here because foo
> may have stored references to a owned resources. But if foo signature is
> `foo(scope ref A a)` then compiler can statically verify that it is safe
> which is the very point of borrowing guarantees. It must be transitive
> to guarantee anything of course.
What is "scope ref" supposed to do in this example, compared to just
"scope"?
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list