Recent

Author Topic: Generic primitives, generic records.  (Read 19336 times)

raistware

  • New Member
  • *
  • Posts: 15
Re: Generic primitives, generic records.
« Reply #15 on: February 26, 2010, 06:54:54 pm »
Well, Lazarus is the tool, but FPC is the compiler. The language is featured by the compiler ;) . If you want to have that feature, it is better that you ask for it on correct place.


@eny: Have you tried any time to read C++ code full of templates? It is big shit that nobody can undertand without weeks of study even for small projects with 10-20 files! I know because I have ported some C++ code to pascal, and even currently I am porting a C++ project to pascal... I only can say that templates are THE HELL!

eny

  • Hero Member
  • *****
  • Posts: 1656
Re: Generic primitives, generic records.
« Reply #16 on: February 27, 2010, 12:53:40 am »
@eny: Have you tried any time to read C++ code full of templates?

No, I prefer to work with FPC/Lazarus (although I have done my share of C++ programming...).

Quote
I only can say that templates are THE HELL!

I don't necessarily disagree with you. However generics are not C++ templates.
Unfortunately the reference guide adds to the confusion by saying in Chapter 8: "As of version 2.2, Free Pascal also officially has support for templates or Generics."
As I mentioned before, generics are an elegant way to create a group of typesafe 'child' classes, based on a generic (no pun intended) class implementation.

Generics have had a rough history though: they worked OK with lazarus 0.9.26, didn't work at all with Lazarus 0.9.27 and have been working OK since Lazarus 0.9.28. I don't know if it was a FPC problem, or Lazarus problem, but with the latest builds they have been working as expected.

And as a final note: they should be used where appropriate  8)
(which is something that applies to all language constructs...)
All posts based on: Win11; Lazarus 4_4  (x64) 12-02-2026 (unless specified otherwise...)

 

TinyPortal © 2005-2018