I feel the dynamic array .sizeof property is kind of a bait and switch

WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 26 09:27:57 PDT 2017


On Wednesday, 26 July 2017 at 02:31:33 UTC, Mike Parker wrote:
> On Wednesday, 26 July 2017 at 02:24:06 UTC, WhatMeForget wrote:
>> [...]
>
> Because .sizeof has nothing to do with how many elements are in 
> the array. It tells you how much space the array itself takes 
> up.

Totally agree.  .length returns the the number of array elements.

> With static arrays, the memory for the elements if part of the 
> array itself, so it is counted in the size. For dynamic arrays, 
> it is not. For .sizeof to report the size of the allocated 
> memory would be incorrect.

OK, Then I assume the critical thing is that dynamic arrays 
memory is
not part of the array itself.  But is this a deal breaker?



More information about the Digitalmars-d-learn mailing list