[fpc-devel] Templates / Generics
Michael Van Canneyt
michael at freepascal.org
Mon Nov 7 22:16:50 CET 2005
On Mon, 7 Nov 2005, Micha Nelissen wrote:
> On Mon, 07 Nov 2005 21:07:42 +0100
> Marc Weustink <marc at dommelstein.net> wrote:
>
> > Params are passed to a procedure define like
> >
> > procedure MyProc(param, param, ..)
> >
> > Arrays are declared like
> >
> > A: array[0..9] of ...
> >
> > And generics.... they are soly defined by the fact that a type has <> in it.
>
> Well generics *are* a kind of "parameterised" type. When you choose types
> for the parameters, then the type is fully defined, just like the result of
> a not-with-outside-interacting procedure would be when it's parameters are
> filled in. When you view it this way, Bram has a point.
>
> I am still a proponent of a keyword btw, which I've documented at wiki:
>
> http://www.freepascal.org/wiki/index.php/Generics#Terms
>
> (just scroll a little upwards). This is because it generalizes better to
> function generics, I think that in "Max<T: TSomeType>(Foo: Type): T" the
> last T feels "out-of-scope", while it doesn't when you have the generic
> keyword because you're defining a "function generic(T) ..."
>
> Of course, these are all minor details compared to actual implementation.
I second this proposal. But I _don't_ think that this is a minor detail.
One of the nice things about (Object) Pascal is the readability.
The <> does away with that.
Michael.
More information about the fpc-devel
mailing list