[fpc-devel] Generics Basics

L505 fpc505 at z505.com
Tue Nov 8 21:33:13 CET 2005

>I am trying to understand what exactly generics are. I read the wiki
>page, but there are lot's of code examples and very few explanations.
>Can someone explain it to me in a (relatively) simple way?
>What problem is it trying to solve?
>And how do generics relate to interfaces?

I had the same problem for a few years. It took me a few months/years to first diagnose
"what the fudge" templates/generics actually were, and what problem they exactly solved. All
the information about generics is pretty non-real world and non-case study on the internet.
It is also hyped by programmers who again seem to show no real world or case studies. But I
can see how they can be useful in theory, nevertheless.

I'm not going to give you a technical explanation on what they are, because someone else can
do that (and I don't have experience with generics, so I'm not qualified to do so).

Here is a vague non-technical explanation:
Basically generics helps you save some Typing and syntax in your units. You can address
several things at once with the same Type. Supposedly, this encourages code reuse. You can
address and create things via a shortcut syntax sort of way.

Myself, I won't be using generics any time in the next few months/year.. as I still have a
lot of experience in the non-generic programming world to gain, before I even think about
generics.  Unless of course, I find a Delphi/freepascal unit or package that uses generics,
then I will make an effort to learn generics.


Note to any visitors:
z505.com is switching servers, site may be down in the next 24-72 hours

More information about the fpc-devel mailing list