On 7/10/2014 9:00 AM, Nick Treleaven wrote:
On 09/07/2014 20:55, Walter Bright wrote:
here's the first one,
to disable postblit:
https://github.com/D-Programming-Language/phobos/pull/2308
BTW I updated that pull, should be less muddled now ;-)
More things that need to happen with Unique:
...
Unique!(int*) u = new int; // must work
That works, it's spelled:
Unique!int u = new int;
I'm unconfortable with that design, as T can't be a class ref or a dynamic
array.
int* p = new int;
Unique!(int*) u = p; // must fail
The existing design actually allows that, but nulls p:
> [...]
If there are aliases of p before u is constructed, then u is not the sole owner
of the reference (mentioned in the docs):
http://dlang.org/phobos-prerelease/std_typecons.html#.Unique
Exactly. It is not checkable and not good enough.
Note that as of 2.066 the compiler tests for uniqueness of an expression by
seeing if it can be implicitly cast to immutable. It may be possible to do that
with Unique without needing compiler modifications.
Also related is whether we use alias this to expose the resource (allowing
mutation but not replacement) or if we use opDispatch. Currently, it uses opDot,
which AFAICT is basically opDispatch. If we use alias this, that's a(nother)
hole exposing non-unique access to the resource.
The holes must be identified and closed.
BTW, I'm amenable to adjusting the compiler to recognize Unique and help out as
a last resort.