[fpc-devel] Generics

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Aug 17 10:52:33 CEST 2007


On Fri, 17 Aug 2007 10:20:13 +0200 (CEST)
Michael Van Canneyt <michael at freepascal.org> wrote:

>[...]
> > > > > What local types are/will be allowed?
> > > > >
> > > > > For example, this is currently not allowed:
> > > > >
> > > > >   generic TTree<T> = class(TObject)
> > > > >   type public   TTreeNode = specialize TNode<T>;
> > > > >   end;
> > > > >
> > > > > And this neither:
> > > > >
> > > > >   generic TTree<T> = class(TObject)
> > > > >   type public
> > > > >     TTreeNode = class
> > > > >       Data: T;
> > > > >     end;
> > > > >   end;
> > > > >
> > > > >
> > > > > OTOH records and pointers are allowed.
> > > > > Will this stay, or is this just not yet implemented?
> > > > Is there a need to support this?

I don't need them.
I'm just asking for the codetools.
So I guess the answer is: Will stay. (read: there are no
further plans).


> > > Well, it seems rather strange that the type block would not allow
> > > all possible types.
> > 
> > Only a few types can be generic as well. Nested classes cause a lot
> > of hidden pitfalls, that's why they aren't allowed.
> 
> OK, probably I should add this to the docs. I assume all types can be
> defined except classes and generics ?

.. and objects and interfaces.

It seems generic objects and interfaces are allowed, but this
is not yet documented.

What about generic records? Will they be implemented?


Mattias



More information about the fpc-devel mailing list