[fpc-pascal] Feature announcement: Dynamic array extensions

Sven Barth pascaldragon at googlemail.com
Fri May 25 08:02:22 CEST 2018


Ryan Joseph <ryan at thealchemistguild.com> schrieb am Fr., 25. Mai 2018,
04:35:

>
>
> > On May 25, 2018, at 1:37 AM, Sven Barth via fpc-pascal <
> fpc-pascal at lists.freepascal.org> wrote:
> >
> > This is currently not supported. And to avoid backwards compatibility
> problems with existing operator overloads you'd probably need to convert it
> to a dynamic array first:
> >
> > === code begin ===
> >
> > a += ['foo'];
> >
> > === code end ===
>
> What is that doing being the scenes? If it’s creating a whole new array
> and appending it then it’s probably pretty inefficient and hopefully can be
> optimized away.
>

Yes, that is what it does. Though a possible optimization would be that the
compiler detects "dynarr := dynarr + [elem]" and converts it to
"Insert(elem, dynarr, High(dynarr))".


> Since dynamic array helpers work could you expose a function that adds an
> element to the array (an grows it if needed) so we could make helpers for
> it? Pushing a value to an array is perhaps the most common function used
> for lists so it makes sense to get that right imo.
>

That function already exists and is called Insert() (see above).

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180525/cac5fd67/attachment.html>


More information about the fpc-pascal mailing list