On Borrow Checking
Walter Bright
newshound2 at digitalmars.com
Sat May 10 23:40:52 UTC 2025
On 5/10/2025 1:17 PM, Richard (Rikki) Andrew Cattermole wrote:
> There is also the mess with ``return ref`` vs ``return``, that can be written as
> ``return scope`` and ``scope return``.
That came about because of the existence of `ref`. Consider `ref int* p`. How do
you model the scope-ness of the reference and the scope-ness of the pointer?
> These both have the same escape set, just a different relationship strength.
Strength??
> This is of course one of the worst design decisions the D community has ever
> implemented with full regret by all parties involved! :)
The concept behind it works fine. The trouble comes with the complexity of all
the pointer constructions, like the invisible use of `this` references.
> This is also a good time to remember that DIP1000 only understands no escape,
> escape into return value OR this pointer.
That's sufficient to prevent an escaping pointer to the stack. It's quite solid.
If you disagree, post a code snippet demonstrating it.
> No multiple output support, which severely limits its capabilities.
It does not severely limit it. Even the Rust manual says it's a rare case. It's
a minor inconvenience that can be refactored away.
More information about the Digitalmars-d
mailing list