[fpc-pascal] Constants in generics

Sven Barth pascaldragon at googlemail.com
Thu Jan 3 17:05:20 CET 2019


Am Do., 3. Jan. 2019, 14:24 hat Alexander Shishkin via fpc-pascal <
fpc-pascal at lists.freepascal.org> geschrieben:

> 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;
>

I'm against that. A constant parameter is a different beast from a type
parameter so requiring a special prefix for them is legitimate. Also this
is more like the normal routine parameter syntax, thus everyone will feel
right at home.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190103/7aad853d/attachment.html>


More information about the fpc-pascal mailing list