A couple of questions about arrays and slices
Cecil Ward
cecil at cecilward.com
Thu Jun 22 05:21:52 UTC 2023
On Thursday, 22 June 2023 at 01:44:22 UTC, Jonathan M Davis wrote:
> On Wednesday, June 21, 2023 7:05:28 PM MDT Paul Backus via
> Digitalmars-d-learn wrote:
>> [...]
>
> To add to that, it _has_ to know the element type, because
> aside from anything related to a type's size, it bit-blits the
> type's init value onto the new elements when it increases the
> length of the dynamic array.
>
> You'd probably be dealing with bytes if you were explicitly
> asking for memory and the like (e.g. with malloc), but a
> dynamic array is properly typed, and everything you do with it
> in @safe code is going to deal with it as properly typed. For
> it to be otherwise would require @system casts.
>
> - Jonathan M Davis
Thankyou Jonathan!
More information about the Digitalmars-d-learn
mailing list