Recent

Author Topic: RTL-Generics supports generic lists of records, but FGL doesn't?  (Read 3155 times)

SlightlyOutOfPhase

  • New member
  • *
  • Posts: 8
« Last Edit: February 21, 2020, 10:41:33 pm by SlightlyOutOfPhase »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: RTL-Generics supports generic lists of records, but FGL doesn't?
« Reply #1 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.

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: RTL-Generics supports generic lists of records, but FGL doesn't?
« Reply #2 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.
« Last Edit: April 02, 2017, 02:46:07 am by Akira1364 »

 

TinyPortal © 2005-2018