Forum > General

The right implementation of generics

(1/10) > >>

simone:
Often I use generics in my programs, but I suspect that they cause internal errors during compilation phase (almost random and difficult to reproduce, but frequent...). I apoligize if my hypothesis is pointless... Indeed I can't dimonstrate a cause-effect relation between generics and internal errors, but in the past I read in the forum users reporting similar problems. I work with FGL, since this is the implementation cited in the language reference of freepascal and because i have read that FGL is the FPC way to generics, whereas rtl-generics is only for delphi compatibility. Conversely, I have also read that rtl-generics is better. So, in order to avoid problems, what is the implementation of generics that I should use? Thanks for the help.

Thaddy:
FGL is an early effort regarding generics in FPC and on its own just works, but in trunk we have rtl-generics and that is, in many ways, faster, better and more stable.
So if it is possible for you to use trunk, please use trunk and use rtl-generics.
Note that the syntax etc for the compiler is already present (back-ported) in FPC 3.0.2, I believe, but the library itself not afaik.

Xor-el:
As weird as it may sound,  I suggest you use rtl generics especially for Delphi compatibility  and ease of use.  O:-)

Thaddy:

--- Quote from: Xor-el on May 26, 2017, 11:53:04 am ---As weird as it may sound,  I suggest you use rtl generics especially for Delphi compatibility  and ease of use.  O:-)

--- End quote ---
It is not weird. Everybody agrees that rtl-generics is superior to fgl. And the implementation is in my opinion superior to Delphi too... Thanks to Maciej (HNB).

simone:
Thanks for explanations. At this point I have other questions (may be silly... thank for patience!):

1) if rtl-generics is superior to fgl, why fpc comes with fgl and language reference only refers to it?

2) can fgl cause internal errors during compilation? If yes, this problem don't arise with rtl-generics?

3) I understand I need to migrate my code to rtl-generics. This unit guarantee some form of backward compatibility with fgl (in particular for TFPGObjectList)?

Navigation

[0] Message Index

[#] Next page

Go to full version