Sign in Join

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

Mailing lists / fpc-pascal / 2010-04

type constraints in generics?

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Thierry Coq

Hello,

please find attached a very simple test of generics. I would like to limit the actual type in this list to be a child class of TObject. Is this possible and if yes, how can it be done?

In a more general question, what are the differences between the FPC generics and the C# generics (the ones used by the newer versions of Delphi)? In addition to the syntax, of course?

Best regards,
Thierry

Reply by email

leledumbo
to Thierry Coq
I would like to limit the actual type in this list to be a child class of

TObject. Is

this possible and if yes, how can it be done?

I don't think it's currently supported. It will be, if someone is willing to do it.

In a more general question, what are the differences between the FPC generics and the C# generics (the ones used by the newer versions of Delphi)? In addition to the syntax, of course?

To the best of my knowledge, FPC generics are based on C++ one, while C# one seems to be coming from Java. FPC one is simply hold as a macro by the compiler when it's declared and written with all generic types resolved when it's specialized. It's all done at compile time. In C# case, it's the runtime environment who is responsible for this. That's why C# one is more dynamic.

View this message in context: http://old.nabble.com/type-constraints-in-generics--tp28375014p28384859.html Sent from the Free Pascal - General mailing list .

Reply by email