[fpc-pascal] Feature announcement: implicit generic function specializations

Hairy Pixels genericptr at gmail.com
Sat Apr 30 15:20:25 CEST 2022



> On Apr 30, 2022, at 7:02 PM, Mattias Gaertner via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> AFAIK it is planned for mode objfpc to support distinguishing types via
> template count as in mode delphi:
> 
> type
> TMyClass = class
> end;
> generic TMyClass<T> = class
> end;
> generic TMyClass<S,T> = class
> end;
> 
> So you would need something similar for helpers:
> 
> THelper = class helper for TMyClass
> end;
> generic THelper<T> = class helper for specialize TMyClass<T> 
> end;
> generic THelper<S,T> = class helper for specialize TMyClass<S,T> 
> end;

Now that would be a duplicate identifier error but that may be changed for Delphi compatibility? That indeed would break any possible shorthands. Maybe at least the specialize could be omitted because of the grammar which is so annoying. :)

To the extent I have a todo list I’ve had plans to make a mode switch for “generic keywords” so you could disable them in Object Pascal mode (Svens idea). That would fix the specialize problem but honestly I kind of like the generic keyword as it’s a prefix and makes the type more clear. It’s the specialize keyword I have a problem with.

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list