[fpc-pascal] Generic: record type restriction

Sven Barth pascaldragon at googlemail.com
Fri Dec 12 19:20:22 CET 2014


Am 12.12.2014 18:44 schrieb "silvioprog" <silvioprog at gmail.com>:
>
> Hello,
>
> I need to restrict a generic type to accept specialization only of enum
types. In Delphi, I can do that using "T: record", but, when I try to use
it in FPC (even using mode delphi), I got:
>
> project1.lpr(16,42) Error: Record type expected
>
> Small project to reproduce the error in attachment.
>
> Is this a normal behavior of the compiler, or is my code a erroneous
approach?

Currently it is normal behavior of the compiler (because back then I didn't
realize that in that context "record" means basically "non-nullable") and
yes, there is already a bug report about it (just look through the
not-resolved and not-closed bug reports with tag "generics"). I'm still
thinking about how to name this better for non-Delphi modes...

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20141212/40636389/attachment.html>


More information about the fpc-pascal mailing list