On Thursday, 11 July 2013 at 07:13:50 UTC, Jacob Carlborg wrote:
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.

It's in the user side. In druntime it is void[] + typeinfo. I am not aware of any part in dmd/druntime where arrays are repsented as templates (or strongly typed) as depicted in this dicsussion. And current treatment can be barely called templatization as there is no templates, template instantiations and typicall horrible mangling at all. More precise description is not templatization but some kind of implicit conversion from array of specific type in source code to void array plus typeinfo in runtime library. If user tries to use struct Array(T) {...} instead of usual arrays he will gain no benefit but useless template bloat.

Reply via email to