[fpc-devel] Templates / Generics
Florian Klaempfl
florian at freepascal.org
Mon Nov 7 23:06:37 CET 2005
Mattias Gaertner wrote:
> 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);
>
> :)
Well, that's no problem either, the compiler knows that the < for
parameter instantiation can only follow types being templates/generics
:) Parsing is usually type driven in fpc.
>
>
>
>>>- <> 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?
I would do so, see my mail from the weekend :)
More information about the fpc-devel
mailing list