> On May 25, 2018, at 1:02 PM, Sven Barth via fpc-pascal 
> <fpc-pascal@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

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to