[fpc-pascal] Interface syntax: Is possible don't use specialize in mode objfpc?

silvioprog silvioprog at gmail.com
Fri Jul 17 16:08:23 CEST 2015

On Fri, Jul 17, 2015 at 3:06 AM, Graeme Geldenhuys <
mailinglists at geldenhuys.co.uk> wrote:

> On 2015-07-17 03:34, silvioprog wrote:
> > TPersonDao = class(TObject)
> > public
> >   procedure Save(APerson: TObject);
> > end;
> Simply change that to the following:
> TPersonDao = class(TObject)
> public
>   procedure Save(APerson: TPerson);
> end;

Yes, it was just a simple and partial demo, but have you seen the following
sample in same e-mail that I sent? Using the generics I could do a generic
DAO that could be used by any class, avoiding TPersonDAO, TProductDAO,
TOtherMyEntityDAO and providing a simple and useful CRUD layer: just
specialize it using a model, something like

Generics are very usefeul, the problem is just the way how something it is
used in some implementation, e.g, using the FGL AFAIK you cannot know the
type of the item from a specializated list class.

and you could have compile time validation too. Using TObject as the
> parameter type is just too generic (excuse the pun). ;-)

OK, no problem. =)

BTW I use correct type as parameters, but I believe you understood what I
meant. =D

Silvio Cl├ęcio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150717/4d04366f/attachment.html>

More information about the fpc-pascal mailing list