Inability to dup/~ for const arrays of class objects

Jonathan M Davis jmdavisProg at gmx.com
Thu May 30 10:52:08 PDT 2013


On Thursday, May 30, 2013 12:56:46 Steven Schveighoffer wrote:
> 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.

Well, we've clearly ended up with a few terms that get re-used with different 
meanings and cause confusion. The terms dynamic array and slices are generally 
used interchangeably by the spec and plenty of D users, whereas you're 
basically arguing that D doesn't even have dynamic arrays. Rather, dynamic 
arrays are basically an implementation feature of druntime. However, trying to 
call them all slices instead of dynamic arrays has its own issues, because 
slices are for more than just arrays - they're a core concept of ranges, many 
of which have no relation with arrays. So, I guess that the best term that we 
have would be array slice (not even dynamic array slice, since it could be a 
silce of a static array). But even if we agreed that that was the correct term 
and fixed the spec, it's still ripe for confusion.

It reminds me of the tuple fiasco. Having the bulit-in tuples that TypeTuple 
wraps called tuples causes all kinds of confusion with std.typecons.Tuple (on 
top of the fact that the built-in tuples arguably aren't even tuples).

We seem to have at least a couple of serious terminology/naming problems on 
our hands, and I'm not sure that we have good solutions for any of them. For 
the moment at least, we're stuck trying to give good explanations in order to 
clarify the situation.

And of course, with the spec, TDPL, and the standard library (e.g. 
isDynamicArray) all using the term dynamic array pretty much interchangeably 
with the term slice when discussing arrays, I don't know that there's any 
chance of really clarifying the situation beyond explaining it to people.

- Jonathan M Davis


More information about the Digitalmars-d mailing list