[fpc-pascal] Constants in generics

Sven Barth pascaldragon at googlemail.com
Thu Jan 3 19:33:42 CET 2019

Am Do., 3. Jan. 2019, 17:50 hat Ryan Joseph <ryan at thealchemistguild.com>

> > On Jan 3, 2019, at 6:20 AM, Sven Barth via fpc-pascal <
> fpc-pascal at lists.freepascal.org> wrote:
> >
> > Correct. ";" separates different parameter types, "," separates those of
> the same type. Though I agree with Mattias that "const T, const U" (with or
> without ": Integer") should not work (but then "T, const U" should also not
> work for consistency).
> > Essentially it should behave like a routine's parameter clause.
> I guess that makes sense that if a type parameter is followed by a const
> parameter then those are essentially different types and following the same
> logic should be separated with a semicolon.
> That means the parser only knows if a ; is required after the const
> keyword is found. Does that matter?

The approach should be like this:
- const is allowed at the start of the parameters or after a ";"
- a parameter name is either followed by a ",", ";", ":" or ">" (that
should already be the case)
- a ":" is either followed by a type constraint (for non const parameters)
or a type name that allows constants (for const parameters); in either case
this is followed by a ";" or the closing ">"

I think that should cover everything 🤔


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

More information about the fpc-pascal mailing list