[fpc-pascal] Constants in generics

Alexander Shishkin alexvins at mail.ru
Thu Jan 3 14:23:56 CET 2019


03.01.2019 15:45, Mattias Gaertner via fpc-pascal пишет:
> On Thu, 3 Jan 2019 14:58:00 +0300
> Alexander Shishkin via fpc-pascal <fpc-pascal at lists.freepascal.org>
> wrote:
> 
>> [...]
>> This is OK (both T and U are integer):
>> generic TMyRecord1<const T, const U: integer> = record end;
> 
> That is inconsistent to normal Pascal arguments.
> 
> <accessors> Name[, Name ...][:type]
> 
> Isn't it?
> 

I personally do not like const prefix either. More consistent with other 
constraints would be:

T and U integer const
generic TMyRecord1<T, U: integer> = record end;
generic TMyRecord1<T, U: const, integer> = record end;

Similar to
generic TMyRecord1<T, U: IUnknown> = record end;
generic TMyRecord1<T, U: class, IUnknown> = record end;

T and U any const
generic TMyRecord1<T, U: const> = record end;

Similar to
generic TMyRecord1<T, U: record> = record end;

And more complex example:

generic TMyRecord1<T, U: record; X, Y: const> = record end;



More information about the fpc-pascal mailing list