[fpc-devel] Templates / Generics
kuifwaremailinglists at xs4all.nl
Mon Nov 7 14:45:19 CET 2005
Micha Nelissen wrote:
> Bram Kuijvenhoven wrote:
>> Florian Klaempfl wrote:
>>> - we'll use a syntax as close as possible to Chrome, e.g.
>>> TList<T> = class
>> I greatly favor this syntaxis above the generic-modifier. It will look
>> at a lot more familiar to most programmers (due to e.g. C++ and Java),
> "Must look familiar" programmers should be fired.
Of course, the implementation of generics in Pascal should not depend solely on how it is implemented in other languages. I should in the first place fit into Pascal.
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.
The only objection might be the ambiguity with the < operator. From that perspective, a solution like generic(T) might seem nice. But a solution for that was already proposed: only allow the use of <> in declaration blocks, not in code. Also, I wouldn't particularly consider genericness a modifier (but like parameters).
Of course it is hard to discuss about matters of taste. Perhaps a poll might help us out here.
Anyway, I think that seeking some syntactical familiarity (when other considerations more or less tie) isn't neccesarily bad.
Consider for example the following: Is Java bad because it looks like C++? Or is PHP bad because is looks like C++? I think it is even advantageous for programmers these languages have a similar syntaxis.
Just as + means addition in most programming languages, <> is used for generics as far as I know in most languages supporting generics.
I think if other considerations tie, we should therefore choose for <> as well. I think this will at least add to popularity and also reduce RSI ;)
More information about the fpc-devel