Inability to dup/~ for const arrays of class objects

Steven Schveighoffer schveiguy at yahoo.com
Thu May 30 09:56:46 PDT 2013


On Thu, 30 May 2013 12:46:39 -0400, Maxim Fomin <maxim at maxim-fomin.ru>  
wrote:

> Please provide reasons why it is wrong (but without explanation how  
> druntime allocates memory which is irrelevant).

It's wrong in that D's spec re-defines dynamic arrays from the traditional  
definition (I think for the sake of simplicity, but I didn't write the  
definition, so I'm not sure).  D's slices aren't dynamic arrays, no matter  
how many specs say so.

> That's nice to hear, but at that point there would be no point for  
> discussions. I see no roots from where contradictory definition in  
> article comes from.

It comes from the experience of observing anyone who knows what a dynamic  
array is, comes to D, sees from the spec that it's T[], and then gets  
confused when T[] does not act like the dynamic array they know from C++,  
Java, C#, etc.

In other words, explaining countless times on the newsgroups how slices  
work prompted me to write the article.  It's not an easy concept to grasp.

-Steve


More information about the Digitalmars-d mailing list