[fpc-pascal] Feature announcement: Dynamic array extensions

Ryan Joseph ryan at thealchemistguild.com
Fri May 25 08:42:55 CEST 2018



> On May 25, 2018, at 1:02 PM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> 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))”. 

100%

> 
> 
> 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). 
> 

Oh Insert on the last element works like Push. There really should be a Push/append etc.. function in there. I know it’s redundant but doing 

Insert(arr, High(arr), value) is more work than Push(arr, value) and it’s not clear if we can add this ourselves easily without making tons of overloads.


Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list