Immutable woes

Bob Cowdery bob at bobcowdery.plus.com
Tue Sep 21 01:02:33 PDT 2010


 Thanks, that at least builds now. I didn't see that trick in the book
but I've found it on the on-line library ref under std.exception. I
can't say I understand why its under std.exception.

bob
 
On 21/09/2010 08:48, Simen kjaeraas wrote:
> Bob Cowdery <bob at bobcowdery.plus.com> wrote:
>
>> if I say something like:
>> float[] xfer = new float[512];
>> xfer = buffer[0 .. $/2];
>> tid.send(xfer);
>>
>> it rightly tells me 'thread local data not allowed'. If I make it:
>>
>> immutable (float)[] xfer;
>> xfer = buffer[0 .. $/2];
>> tid.send(xfer);
>>
>> it tells me 'can't implicitly convert float[] to immutable (float)[]'
>>
>> If I try a float by float copy into xfer it can't because I've said the
>> buffer is immutable. In the first example I can't figure out how to
>> convert the slice into an immutable copy which I think is what I should
>> be doing.
>>
>> Can someone point me in the right direction.
>
> http://www.digitalmars.com/d/2.0/phobos/std_exception.html#assumeUnique
>
> float[] xfer = new float[512];
> xfer = buffer[0 .. $/2];
> tid.send(assumeUnique(xfer));
>
> This should solve your problems.
>



More information about the Digitalmars-d-learn mailing list