[fpc-devel] Templates / Generics
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Nov 7 23:02:52 CET 2005
On Mon, 07 Nov 2005 22:41:06 +0100
Florian Klaempfl <florian at freepascal.org> wrote:
> Mattias Gaertner wrote:
> > On Mon, 07 Nov 2005 19:29:51 +0100
> > Bram Kuijvenhoven <kuifwaremailinglists at xs4all.nl> wrote:
> >
> >
> >>Micha Nelissen wrote:
> >>
> >>>On Mon, 07 Nov 2005 14:45:19 +0100
> >>>Bram Kuijvenhoven <kuifwaremailinglists at xs4all.nl> wrote:
> >>>
> >>>>Does <> for generics fit into Pascal? Well, we use [] for array
> >>>
> >>>indexing, and () for parameter passing to procedures/functions/methods.
> >>>So why not use <> for passing parameters to generic types? And, similar
> >>>to the case of function calls and array indexing, these <> could follow
> >>>the type identifier directly.
> >>>
> >>>You got a point here, but the "where T is Foo" stuff is crap then,
> >don't >>you agree?
> >>>
> >>>TGType<T: TBaseType> = class(...) ... end;
> >>>
> >>>is better then, when compared to your parameter example.
> >>
> >>I indeed don't like the "where T is foo" of Chrome :) So you are totally
> >>right, TGType<T : TBaseType> is a lot better and a lot more consistent
> >>(with e.g. function parameter syntaxis).
> >
> >
> > Let's sum up the different points for the syntax so far:
> >
> > - <> will probably be used by Delphi
> > - <> bites the < operator
>
> No, as I said, we should allow template instantiation only in type blocks.
type
TMyType = boolean(a<b)..(a>b);
:)
> > - <> makes the parser more difficult and slow
>
> See above.
>
> > - <> makes pascal more ambigious
>
> See above.
>
> > - alternatives: modifiers or not yet used brackets like (! !) or (# #)
>
> Ugly :)
Sure. But some people like emoticons. !)
> > It seems to me, it's a question of: Follow Delphi generics or not.
> > And we don't know, where Delphi will go. They will not have generics in
> > the next one and a half year and as always: They will do a few things
> > completely different than expected.
> > If we follow, then we will do, as Florian et al said.
> > If not, then the <> is not the best solution.
> >
> > Is this correct so far?
Ok. So, FPC will follow chrome/Delphi?
Mattias
More information about the fpc-devel
mailing list