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

Sven Barth pascaldragon at googlemail.com
Mon Apr 25 11:11:04 CEST 2022

Hairy Pixels via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Mo., 25. Apr. 2022, 10:58:

> > On Apr 25, 2022, at 2:39 PM, Martin Frb via fpc-pascal <
> fpc-pascal at lists.freepascal.org> wrote:
> >
> > Actually, it's dealing with SmallInt (or ShortInt). And if the
> programmer does not know that, then it might be an issue...
> >
> > Imagine the generic code (something more complex than "Add") would
> somehow do something that differs for SmallInt and Integer. Like using
> "SizeOf(T)".
> This is almost a case that requires better type restrictions. If your
> generic function relies specifically on some particular type information
> this is almost not really even a good candidate to be generic at all.

Then you don't think creative enough. Think about (de)serialization code
for binary data which needs to use the correct size. If done correctly this
can very well be handled with a generic.


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

More information about the fpc-pascal mailing list