[fpc-pascal] Feature announcement: implicit generic function specializations

Sven Barth pascaldragon at googlemail.com
Mon Apr 25 14:14:35 CEST 2022

Mattias Gaertner via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb
am Mo., 25. Apr. 2022, 13:50:

> >[...]
> > type
> >   generic TArrayHelper<T> = type helper for array of T
> >     procedure Add(value: T);
> >   end;
> >
> > var
> >   a: array of integer;
> > begin
> >   a.Add(1);  // specialize TArrayHelper<Integer> since the compiler
> > clearly knows the type used is Integer. end.

For some reason I don't get all mails by Ryan, so I reply here:

Helpers currently can't be generic and even if they could be (which I do
plan to add) it would require an explicit specialization of the helper to
be used because the compiler will not be tasked with searching for
potential generic helpers and then implicitly specializing a whole helper
type with all its methods to maybe use it for an implicit specialization
(and it needs to specialize the helper first to decide whether it even
remotely contains suitable methods).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20220425/4dbd3289/attachment.htm>

More information about the fpc-pascal mailing list