Recent

Author Topic: [SOLVED] generics with constraints not working  (Read 3162 times)

blochee

  • New Member
  • *
  • Posts: 16
[SOLVED] generics with constraints not working
« on: May 04, 2014, 03:06:00 am »
Hello fellow programmers.

I've have another "simplette" (a simple problem).

The following does not work:

Code: [Select]
type
    generic TExample10<T1: class; T2> = class
    end;

begin
end.

The error given:

testing_ground.lpr(2,26) Fatal: Syntax error, ">" expected but ":" found


This example was taken straight from the net at the following site:

http://free-pascal-general.1045716.n5.nabble.com/Feature-announcement-Generic-type-constraints-td5712290.html


Now, that example was posted in Dec, 2012 and I just upgraded to fpc 2.6.4.

Anybody know how to solve the problem?
« Last Edit: May 04, 2014, 09:08:59 pm by blochee »
Lazarus Version #: 1.2.4
FPC Version: 2.6.4
SVN Revision: 45510
x86_64-linux-gtk 2
Ubuntu 14.04 LTS

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: generics with constraints not working
« Reply #1 on: May 04, 2014, 05:44:38 am »
Most (if not all) of generics features and bug fixes are only available in trunk. 2.6.X will never get generics patches backported, the changes are too radical.

blochee

  • New Member
  • *
  • Posts: 16
Re: generics with constraints not working
« Reply #2 on: May 04, 2014, 09:08:18 pm »
Thanks!  I got the latest trunk and it works.  If anybody else is reading this and is having the same problems, you can find how to install the trunk at:

http://wiki.lazarus.freepascal.org/Getting_Lazarus#Getting_SVN
Lazarus Version #: 1.2.4
FPC Version: 2.6.4
SVN Revision: 45510
x86_64-linux-gtk 2
Ubuntu 14.04 LTS

 

TinyPortal © 2005-2018