Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2021-04

Generic constants with generic type

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrey Zubarev

Hi all!
With the existing syntax of constants, it is good to pass array boundaries, but bad to initial parameter values. What do you think about such constructs:

GTValue<GValueType; const GMin,GDefault,GMax:GValueType>=...

Sven Barth
to Andrey Zubarev

Andrey Zubarev via fpc-pascal schrieb am
Mi., 21. Apr. 2021, 09:23:

Show quoted text 7 lines
Hi all! With the existing syntax of constants, it is good to pass array boundaries, but bad to initial parameter values. What do you think about such constructs: GTValue<GValueType; const GMin,GDefault,GMax:GValueType>=...

It is currently simply not possible to reference earlier type parameters inside the parameter clause. This affects code like this as well: generic TSomeGeneric<T; S: ISomeOtherGeneric<T>>
Once that is fixed your case will probably work as well as long as the type is one for which untyped constants can be declared.

Regards,
Sven

Andrey Zubarev
to Sven Barth

Ok. Thanks!
For this already there is a bug report? to notice when it will work?

On Wed, Apr 21, 2021 at 2:12 PM Sven Barth via fpc-pascal <

Show quoted text 26 lines
wrote: Andrey Zubarev via fpc-pascal schrieb am Mi., 21. Apr. 2021, 09:23: > Hi all! > With the existing syntax of constants, it is good to pass array > boundaries, but bad to initial parameter values. What do you think about > such constructs: > > GTValue<GValueType; const GMin,GDefault,GMax:GValueType>=... > It is currently simply not possible to reference earlier type parameters inside the parameter clause. This affects code like this as well: generic TSomeGeneric<T; S: ISomeOtherGeneric<T>> Once that is fixed your case will probably work as well as long as the type is one for which untyped constants can be declared. Regards, Sven > _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal