Inability to dup/~ for const arrays of class objects

Steven Schveighoffer schveiguy at yahoo.com
Thu May 30 19:07:56 PDT 2013


On Thu, 30 May 2013 20:05:59 -0400, Peter Williams  
<pwil3058 at bigpond.net.au> wrote:

> On 30/05/13 16:21, Ali Çehreli wrote:
>> On 05/29/2013 06:54 PM, Peter Williams wrote:
>>  > I find the mechanism described in the article a little disconcerting  
>> and
>>  > it certainly needs more publicity as it's a bug in waiting for the
>>  > unwary.
>>
>> It certainly is disconcerting. Performance have played a big role in the
>> current semantics of slices.
>
> I should have added that it was the non determinism that disconcerted  
> me.  It doesn't really affect me personally as a programmer now that I  
> know about it as I can just avoid it.  But it blows out of the water any  
> hopes of having "proveably correct"  non trivial code.

I think this is an overstatement.  It depends heavily on what you are  
doing, and most usages will be correct.

You can achieve deterministic behavior depending on what you are looking  
for.  For certain, you can tell without any additional tools that an  
append will not reallocate if the capacity is large enough.

-Steve


More information about the Digitalmars-d mailing list