[fpc-pascal] Constants in generics

Alexander Shishkin alexvins at mail.ru
Thu Jan 3 01:52:40 CET 2019


Thanks, now I`ve lost is a discussion again. What is the decision about 
syntax? Is "const" prefix and/or ": type" suffix required?


generic TList1<T, U> = class
   var data: array[0..U] of T; end;

generic TList2<T; U: Integer> = class
   var data: array[0..U] of T; end;

generic TLis3<T; const U> = class
   var data: array[0..U] of T; end;

generic TList4<T; const U: integer> = class
   var data: array[0..U] of T; end;



03.01.2019 2:15, Sven Barth via fpc-pascal пишет:
> Am Mi., 2. Jan. 2019, 23:41 hat Alexander Shishkin via fpc-pascal 
> <fpc-pascal at lists.freepascal.org 
> <mailto:fpc-pascal at lists.freepascal.org>> geschrieben:
> 
>     06.11.2018 10:13, Ryan Joseph пишет:
>      >
>      > program generic_constants;
>      >
>      > type
>      >       generic TList<T, U> = record
>      >               list: array[0..U-1] of T;
>      >               function capacity: integer;
>      >       end;
>      >
> 
>     I`d like to see constant parameter to be constrained with type
> 
>        type
>              generic TList<T; U: Integer> = record
>                      list: array[0..U-1] of T;
>                      function capacity: integer;
>              end;
> 
> 
> That's already been taken care of by Ryan :)
> 
> Regards,
> Sven
> 
--AVS




More information about the fpc-pascal mailing list