The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Impossible: Property using Generics in Delphi. Interfaces/classes/methods/fields/constraints/type inferencing are

Posted by jpluimers on 2013/01/30

Just in case you wonder about Property using Generics in Delphi, they are not possible.

Thanks David for mentioning it, Hallvard for mentioning it even earlier and Rudy for confirming it.

These are supported with Generics in Delphi:

All of the supported aspects are linked to articles from excellent authors. There is far more on the internet about Delphi and Generics, but those are a good start.

Thanks Malcolm, Phil, Barry, Hallvard, Jolyon and many others for posting all those articles!

Note that this is not possible in C# either, Julian Bucknall organized a chat and explains why, but there is a workaround which I might try to port to Delphi in the future.

–jeroen

via: Property using Generics in Delphi – Stack Overflow.

3 Responses to “Impossible: Property using Generics in Delphi. Interfaces/classes/methods/fields/constraints/type inferencing are”

  1. hvassbotn's avatar

    hvassbotn said

    Hi Jeroen,

    Thanks for the mention :).

    I did point this out in my old Delphi for .NET article, actually :)

    “Although, one might think that having support for generic properties as well would be a natural extension (after all a property just maps to getter and setter methods, after all), but indeed this is not possible. I don’t think C# supports this, either, btw.

    type
    // Generic property – not supported
    TBar = class
    procedure SetGenericProperty(const A: T);
    function GetGenericProperty: T;
    // NOTE: Is this not allowed – Would be cool?!
    property GenericProperty: T read GetGenericProperty write SetGenericProperty;
    end;”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.