[fpc-pascal] Constants in generics
Ryan Joseph
ryan at thealchemistguild.com
Tue Nov 27 08:18:06 CET 2018
> On Nov 27, 2018, at 4:59 AM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>
> Best check again once you've done the switch to tconstsym for constants. :)
>
I made most of the changes you mentioned so please look. Including the constsyms didn’t break anything and helped to clean up the code. I would have done that from the start but I wasn’t sure you wanted me mixing in new types.
Some things remaining:
1) kSomeDays is a typed const so I get a load node instead of tsetconstnode, which I need to need to know in order to make the name string. See the TODO’s in tgenericparamdef.create.
type
TDay = (Mon, Tue, Wed);
TDays = set of TDay;
const
kSomeDays:TDays = [Mon, Wed];
var
d: specialize TMyRecord_Set<integer,kSomeDays>; // this doesn’t work
d: specialize TMyRecord_Set<integer,[Mon,Wed]>; // this works because I get a set node
2) Again in tgenericparamdef.create I don’t know how to make the pretty name string from a set (see the TODO)
3) You may be right about forcing the const type at declaration. I still kept the undefined const placeholder in there but if you have nested specializations you can get type errors because the placeholder uses a nil node. It’s too early to know if there’s any reason for undefined consts.
4) I’m not sure if changing the types to consts messed up PPU loading or it works out of the box. Seems to be ok from initial tests though.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list