Lazarus

Free Pascal => General => Topic started by: SlightlyOutOfPhase on March 26, 2017, 12:59:32 am

Title: RTL-Generics supports generic lists of records, but FGL doesn't?
Post by: SlightlyOutOfPhase on March 26, 2017, 12:59:32 am
.
Title: Re: RTL-Generics supports generic lists of records, but FGL doesn't?
Post by: marcov on March 26, 2017, 11:18:20 am
Just use rtl-generics. fgl is more something designed when the generics support was still new, it's designed around generics limitations of that time and while fixes were applied it was never conceptually updated after.

As usual, the main benefit is that it is small and on RTL level and can be used for utils that can't use packages.

Even fcl-stl is slightly better.
Title: Re: RTL-Generics supports generic lists of records, but FGL doesn't?
Post by: Akira1364 on March 27, 2017, 01:53:51 am
If I recall correctly this is specifically related to the way the list classes in FGL implement the IndexOf function... by which I mean, they use the actual = operator to compare list items. If for whatever reason you're absolutely dead set on using FGL, you could modify your copy of FGL.pp to use something like CompareByte instead of = in those functions, and it would then be able to create lists of any type. However, in my opinion that wouldn't really be worth it at all, and as Marco said you should really just use RTL-Generics. Not only does it have a lot more features than FGL, but it's also significantly more performant.
TinyPortal © 2005-2018