[Issue 17065] [REG2.072] Unique does not work with private members

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jan 17 15:58:31 PST 2017


https://issues.dlang.org/show_bug.cgi?id=17065

Martin Nowak <code at dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code at dawg.eu

--- Comment #5 from Martin Nowak <code at dawg.eu> ---
I'm for reverting this change (the Proxy part).

Proxy is a horrible hack that employ a giant template machinery and was only
introduced to replace typedef. It's main difference from alias this being, that
you cannot implicitly convert it to the type.

Unique should work like this, but cannot until -dip1000 became default.

static if (class_or_interface)
    T get() return scope { return _p; }
else
    ref T get() return { return *_p; }

alias this get;

This does allow implicit conversion, but binds the lifetime of the returned
class ref/ref to the lifetime of Unique, thus making it impossible to escape.

It'll still take a while until that works, and we're likely to come up with new
RC implementations after that (b/c both Unique and RefCounted leave a lot to
wish).

Also opDot isn't going away for a while (and maybe be could be replaced with
opDispatch).

See https://trello.com/c/pTlDuyBD/31-finish-smartref-implementation for
previous attempts on fixing Unique/RefCounted.

--


More information about the Digitalmars-d-bugs mailing list