Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-12

Generic: record type restriction

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

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?

Thank you!

Silvio Clécio My public projects - github.com/silvioprog

Reply by email

Sven Barth
to silvioprog
"silvioprog" wrote
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:

Show quoted text 6 lines
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

Reply by email