Inability to dup/~ for const arrays of class objects

Maxim Fomin maxim at maxim-fomin.ru
Wed May 29 22:40:59 PDT 2013


On Wednesday, 29 May 2013 at 23:45:04 UTC, Ali Çehreli wrote:
> On 05/29/2013 03:59 PM, Peter Williams wrote:
>
> > I've been trying to find out how non ref array arguments are
> passed to
> > functions in D but can't find any documentation on it.
>
> The following concepts are relevant:
>
> - Dynamic array: Maintained by the D runtime

Generally yes, but not always http://dpaste.dzfl.pl/ffbcb449

> - Fixed-length array (aka static array): Can be on the stack
>
> - Slice: An efficient tool to access a range of elements (of 
> any type of array)
>
> Usually, it is the slice that gets passed:
>
>   void foo(int[] slice);

Isn't it a dynamic array? I don't understand listing slice as 
separate type of arrays or mixing meaning of slice and dynamic 
array. As far as D spec is concerned, slice is a SliceExpression 
which produces dynamic array for array types.

> A slice is made up of the pointer to the first element and the 
> number of elements:
>
> struct __SomeImplementationDependentName__
> {
>     size_t length;
>     void * ptr;
> }
>
> Ali



More information about the Digitalmars-d mailing list