Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Difference between FPC Generics and Delphi Generics?

  1. #11
    Quote Originally Posted by chronozphere View Post
    Btw, is it possible to use Type Parameter bounds, like java has? It means that you can enforce that your type-parameter T must be a derivative of a specific class, like this:
    A text worth mentioning: http://sjrd.ftp-developpez.com/tutor...i-generics.pdf.

    Answering your question: yes, it is. As you will see in the article, there is few methods to do so. A little extract from the article, which I put below, provides you with an answer:
    Code:
    type
    TStreamGenericType<T: TStream> = class
    end;

  2. #12
    Ah thanks. I'll read that!

    And how about FPC? Does it have this feature too?
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  3. #13
    Looks like Paul Ishenin is updating Delphi mode generics in FPC heavily those days, so it might be safe to just use the Delphi generics style for now
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  4. #14
    Thanks for the heads up mate! That makes my life a whole lot easier.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  5. #15
    I'm having some trouble converting my Delphi generics to FPC.

    FManaButtons: {$ifdef FPC}specialize{$endif} TObjectList<TManaButton>;

    Error: Specialization is only supported for generic types

    This not works in FPC?

  6. #16
    Records Types with Procedures also does not works? =(

  7. #17
    Quote Originally Posted by wagenheimer View Post
    I'm having some trouble converting my Delphi generics to FPC.

    FManaButtons: {$ifdef FPC}specialize{$endif} TObjectList<TManaButton>;

    Error: Specialization is only supported for generic types

    This not works in FPC?
    The TObjectList in fpc isn't generic
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  8. #18
    Quote Originally Posted by wagenheimer View Post
    Records Types with Procedures also does not works? =(
    Upgrade to FPC in trunk and use Delphi mode. It's partially supported there. It just got implemented less than a month ago, and I'm not sure it's stable, but I haven't had any problems with it during my quick tests

    The same goes for Delphi style generics. The current trunk version in delphi mode can do inline specialization just like delphi. But again, this is very, very new stuff
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  9. #19
    The same goes for Delphi style generics. The current trunk version in delphi mode can do inline specialization just like delphi. But again, this is very, very new stuff
    Awesome Awesome!! Hope these new features will become "stable" soon.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  10. #20
    Ok, seems like they implemented it:

    http://wiki.lazarus.freepascal.org/F...Features_Trunk

    I'd like to test it, but I don't know what to download. Is this only available through the development trunk? Are there any automatic builds (FPC + Laz) containing these changes?

    Thanks

    Edit: I have downloaded and installed the latest version, which I found at this page:
    http://www.hu.freepascal.org/lazarus/
    But it doesn't work yet. Do these packages also contain the latest FPC builds?
    Last edited by chronozphere; 03-02-2011 at 01:31 PM.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •