Jump to content
Json

Implementation of procedure <T: Record>

Recommended Posts

unit Unit2;

interface

uses
   System.Classes;

type
  TTestClass = class
  public
     procedure Test<T: record>;
  end;

implementation

//procedure TTestClass.Test<T: record>;
//begin
//    [dcc32 Error] Unit2.pas(21): E2029 ',', ';' or '>' expected but ':' found
//end;

procedure TTestClass.Test<T>;
begin

end;

end.

 

Delphi 11.3

Why do I need to leave out  : record in the implementation for the code to compile?

 

 

 

Share this post


Link to post

Because the language spec - pardon, the compiler - says so.

 

Constraints on generics are part of the declaration.

Edited by Stefan Glienke
  • Like 2
  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×