Inability to dup/~ for const arrays of class objects

Jonathan M Davis jmdavisProg at gmx.com
Thu May 30 13:33:43 PDT 2013


On Thursday, May 30, 2013 16:15:36 Andrei Alexandrescu wrote:
> > It would be good if Walter or Andrei comment on this.
> 
> Not sure I understand the context.

The D spec uses the terms dynamic array and slice interchangeably. TDPL and 
Phobos do the same. However, Steven has argued that using the term dynamic 
array for a slice is incorrect and goes against how the term is normally 
defined in computer science, because dynamic arrays own their memory, and 
slices don't. So, in his article on arrays which is on dlang.org, he basically 
uses the CS terminology and says that the spec is incorrect in calling T[] a 
dynamic array.

Some people around here (like Steven) are of the opinion that the spec is 
wrong in calling T[] a dynamic array (as it doesn't own its memory like a 
dynamic array would per CS). Others (like Maxim) are arguing in favor of the 
spec or at least that people should be using terms that follow the spec rather 
than trying to claim that T[] is not actually a dynamic array and that the 
dynamic array is the runtime-owned memory and T[] is merely a slice to it (in 
which case, D technically wouldn't even have dynamic arrays except as an 
implementation detail of druntime).

So, Maxim wants clarification from you and/or Walter on what the correct 
meaning for dynamic array is - is T[] both a dynamic array and a slice, or is 
the dynamic array only the chunk of memory owned by druntime, and T[] is only 
a slice? Maxim started the "Dynamic array and slices (need Walter and Andrei 
decision)" thread in order to try and get that clarification.

- Jonathan M Davis


More information about the Digitalmars-d mailing list