[fpc-pascal] Array clearing
Ryan Joseph
ryan at thealchemistguild.com
Wed Apr 12 16:50:09 CEST 2017
> On Apr 12, 2017, at 9:43 PM, Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:
>
> "clear" is not very clear to me ;-)
> IMO SetLength(array,0) is clearing too.
SetLength resizes memory so there’s that distinction. The fact there is an API is what’s important because there’s at least a reference point.
>
> The function you want should be called "Fill".
> For example a function
>
> Array.Fill(DefaultValue);
Good idea. Any defined function is preferable.
>
> But what happens to a multi-dimensional (dynamic) array?
> For example, how to handle this case:
>
> Type MyType = record
> A : Integer;
> B : array of char;
> C : array of Float;
> end; // of record
> ArrayA = array of MyType;
> ArrayB = array of ArrayA.
>
> What would be the DefaultValue for
>
> ArrayB.Fill(DefaultValue);
That’s one of the reasons we won’t be seeing this function any time soon. ;)
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list