> On May 25, 2018, at 12:43 PM, Michael Van Canneyt <mich...@freepascal.org> 
> wrote:
> 
> I think the above is "right", and completely equivalent to sets, which are in 
> some ways
> like an array: a "collection" of same typed values.
> 
> To add an element to a set you also do
>  MySet:=MySet+[aValue];
> 
> That said, sets do have
>  Include(MySet,AValue);
> to include a single value.
> 
> Maybe this syntax can be extended to dynamic arrays.

We can do + operator overloads on array classes though so it’s not totally 
crazy to see this syntax in code. Ultimately if it’s optimized well doing [xx] 
is no big problem I suppose.

Having said that my feeling with dynamic arrays is that they’re more difficult 
to use than collection classes and lack basic functionality (until perhaps just 
now) so why use them? I just got burned really bad by some call to 
FPC_INTERLOCKEDINCREMENT64 from dynamic arrays which killed performance (who 
knows why) so I had to pull them out of all my code just in case.

The procedural syntax of Insert(arr, 0, value) is less enticing than 
arr.Insert(0, value) also but again we can fix that with type helpers.

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