pointers, assignments, Garbage Collection Oh My?

Jacob Carlborg doob at me.com
Thu Jul 11 00:13:49 PDT 2013


On 2013-07-11 04:59, Maxim Fomin wrote:

> To be pedantic dynamic arrays are implemented in D simply as
>
> struct Array
> {
>      size_t length;
>      void* ptr;
> }
>
> and there is no type parametrization since such arrays handling is
> opaque for users (in druntime they are treated as void[]).
> Parametrization can be useful in user side since performing any
> operations with structure above (void*) will lead to errors. But in user
> side there is no point in manipulating the structure directly, as it can
> be done using usual properties/druntime without template bloat. By the
> way, the style ABI page is written, allows implementation to have more
> fields.

typeof("asd".ptr) gives back immutable(char)*, not immutable(void)*. So 
from a user point of view it's as if the array is templated.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list