Recent

Author Topic: fpc 3.2.0 generics.collections  (Read 4701 times)

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
fpc 3.2.0 generics.collections
« on: September 02, 2019, 10:46:36 am »
"FPC has had official support for generics in {$mode ObjFPC} since version 2.2. and in {$mode Delphi} since version 2.6.0.
Generics are sometimes called parameterized types.
The reason that FPC supports two different dialects is simply that FPC implemented generics several years before Delphi.
It is possible to use units written in {$mode ObjFPC} syntax in other units that use {$mode Delphi}, and vice versa.
The Free Generics Library or FGL is an FPC-native collection of generic containers written in {$mode ObjFPC}.
The rtl-generics package is a larger, somewhat more featureful collection of generic containers written in {$mode Delphi} that tries to be compatible with the Delphi generics library. This package is provided as standard in FPC 3.1.1.+ but there is a version for FPC 3.0.4. available.
Both FGL and rtl-generics can be used in both syntax modes."
https://wiki.freepascal.org/Generics

I'm pleased to finally announce next release of rtl-generics aka Generics.Collections 2.0
version for trunk available in trunk ;)
version for 3.0.4 available at : https://github.com/maciej-izak/generics.collections

I was kicked away today from FPC core team (by Michael Van Canneyt).
...
I will continue my all work as much as possible with NewPascal (which will be synced with FPC trunk few times in the year - or more often if needed), I mean here all stuff, including updates for Generics.Collections library, bug fixes for compiler and generics, smart pointers/ARC/nullable types, oxygene mode, closures and extended RTTI.
I've suspended the NewPascal foundation (it was not officially registered yet) and the idea of the NewPascal for the good of whole community (finally one project is better than divided community). I was trying to put all my energy into official FPC but it seems impossible. Every person has a dignity, and the unacceptable line of insulting in many fields was crossed many times.

Note about Generics.Collections:
the library is important for many programmers, so everyone who is using Generics.Collections should use :
https://github.com/maciej-izak/generics.collections
the FPC trunk version will be not updated anymore so if someone is using this library should definitely not use official FPC trunk version. Any bug report about Generics.Collections should be filled in my github repo (in current situation usage of official bug tracker in this matter has no sense).
The next place with actual Generics.Collections will be http://NewPascal.org distribution (which will be updated soon) - the distro was not intensively update because I was too much naive in my faith for FPC progress. NewPascal was intended as part of official FPC which in current situation is impossible.
http://newpascal.org/assets/modern_pascal_introduction.html
Is NewPascal dead?
Is rtl-generics in pair with https://github.com/maciej-izak/generics.collections ?

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.
As weird as it may sound,  I suggest you use rtl generics especially for Delphi compatibility  and ease of use.  O:-)
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).
With the appeareance of the new rtl.generics on FPC 3.2.0, will FGL be deprecated?
« Last Edit: September 02, 2019, 10:56:58 am by valdir.marcos »

Thaddy

  • Hero Member
  • *****
  • Posts: 14367
  • Sensorship about opinions does not belong here.
Re: fpc 3.2.0 generics.collections
« Reply #1 on: September 02, 2019, 11:12:24 am »
http://newpascal.org/assets/modern_pascal_introduction.html
Is NewPascal dead?
Is rtl-generics in pair with https://github.com/maciej-izak/generics.collections ?
No clue about newpascal...
But Yes, the version for 3.0.4 on Maciej's site is - for user purposes - aligned with trunk and 3.2.0  except for some minor - internal! - ways that are now supported by the compiler.
This library by itself was responsible for a whole load of fixes to the compiler and rtl.
Quote
With the appeareance of the new rtl.generics on FPC 3.2.0, will FGL be deprecated?
No, because it has its own use: less complex for instance. The core team is reluctant to deprecate things anyway, especially high level units.
I am very glad there are multiple solid generics libraries: fcl-stl, fgl, rtl-generics.
Note they are just this: libraries that use a new (it is not that new, FPC supported generics way before Delphi) language feature, they are not that language feature itself.
There are many small examples inside the rtl units that also use the feature. Some of them written by me, like a generic IfThen() and some more very small ones.

A quick sum-up might read like this:
- FGL: a show case with well-known algorithms to demonstrate the generics feature ( objpas style)
- FCL-STL: tries to implement well-known algorithms in a C++ standard template library style
- RTL-GENERICS: tries to be Delphi compatible, also tries to implement well-known algorithms in the most optimized way.

Note that NONE of this is a generalization: lot's of overlap and if's and but's....All are well written and supported. There are even more good generics libraries.
As you might have noticed from some of my forum postings I actually use all three...
« Last Edit: September 02, 2019, 11:35:20 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11447
  • FPC developer.
Re: fpc 3.2.0 generics.collections
« Reply #2 on: September 02, 2019, 02:24:30 pm »
Note while not deprecated per se, it is recommended to use rtl-generics as much as possible for new development IMHO

HenrikErlandsson

  • New Member
  • *
  • Posts: 33
  • ^ Happy coder :)
    • Coppershade
Re: fpc 3.2.0 generics.collections
« Reply #3 on: September 07, 2019, 01:13:29 am »
Noob here, battling a Uses Generics.Collections that prevents me from compiling. This points me to RTL, which in turn points me to FPC source zips.

Am I to take this as this will not compile unless I first compile a later FPC than 3.0.4 (latest stable)? Just not sure I'm equipped for that yet.

I absolutely do not mean to hijack the thread, only to comment on the most relevant thread rather than create some duplicate thread. Thanks. :)
Pushed on stack: 6502 / Z80 / Amiga / ARM assembler, Pascal, Delphi, Lingo, Obj-C, Lua, FPC, C# + web front-/backend.

Thaddy

  • Hero Member
  • *****
  • Posts: 14367
  • Sensorship about opinions does not belong here.
Re: fpc 3.2.0 generics.collections
« Reply #4 on: September 07, 2019, 07:57:43 am »
3.2.0 is already available as precompiled distribution for many platforms, so use that. or install it on 3.0.4 from fpcdeluxe (sparta generics)
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

HenrikErlandsson

  • New Member
  • *
  • Posts: 33
  • ^ Happy coder :)
    • Coppershade
Re: fpc 3.2.0 generics.collections
« Reply #5 on: September 07, 2019, 04:48:37 pm »
Thanks. Installed Lazarus+FPC 3.2.0 and got a bit further. But it's best to ask about that in a separate thread, I feel.
Pushed on stack: 6502 / Z80 / Amiga / ARM assembler, Pascal, Delphi, Lingo, Obj-C, Lua, FPC, C# + web front-/backend.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: fpc 3.2.0 generics.collections
« Reply #6 on: September 09, 2019, 11:42:48 am »
Note while not deprecated per se, it is recommended to use rtl-generics as much as possible for new development IMHO
For small, embedded platforms FGL might be more optimal regarding size than rtl-generics, so one can't generalize here. ;)

 

TinyPortal © 2005-2018