[Dlang-internal] DIP1000 discussion and testing

Dicebot via Dlang-internal dlang-internal at puremagic.com
Sat Oct 29 04:30:46 PDT 2016


On 10/27/2016 12:43 PM, Walter Bright wrote:
> I think I thought of a solution. Currently, the design ignores 'scope'
> if it is applied to a variable with no indirections. But we can make it
> apply, in that the 'scope' of a function's return value is tied to the
> 'scope' of the argument, even if that argument has no indirections.
> 
> This should make Dicebot's design work.

This is the step in the right direction but doesn't fix more general
issue. While RNG engine example doesn't have any indirections, that
won't be true in all cases where one needs to return a scoped range.

Most obvious problem is an owning container type:

struct Tree (T)
{
    private Node!T* head;

    ~this ( ) { delete this.head; }

    TreeRange range ( ); // returned range must not outlive
                         // this struct instance
}

There really needs to be a way to bind returned value lifetime to `this`
explicitly. No special cases, no magic, just one of straightforward use
cases.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/dlang-internal/attachments/20161029/da3acdcf/attachment.sig>


More information about the Dlang-internal mailing list