Opportunities for D

Nick Treleaven via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 10 09:00:39 PDT 2014


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;

>    int* p = new int;
>    Unique!(int*) u = p;         // must fail

The existing design actually allows that, but nulls p:

     int* p = new int;
     Unique!int u = p;         // ok
     assert(p is null);
     assert(!u.isEmpty);

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

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.

BTW, should isEmpty be documented? It seems to be public ATM.


More information about the Digitalmars-d mailing list