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

Hairy Pixels genericptr at gmail.com
Sun May 1 05:36:52 CEST 2022



> On Apr 30, 2022, at 6:17 PM, Hairy Pixels <genericptr at gmail.com> wrote:
> 
> 2) Right now helpers only support single types but they would need to be extended to support “array of T”, “set of T”,which by, why aren’t those supported as it is? I can’t seem to think of any reason they should be disallowed. The alternative is using an auxiliary generic type which kind of confounds things because then you’re extending a new type instead of the underlying array of set type.

Looking at this problem this morning and I wanted to give an example of what I was talking about.

type
  generic TArray<T> = array of T;
  generic TMyHelper<T> = type helper for specialize TArray<T>
  end;
  TIntHelper = specialize TMyHelper<Integer>;

The problem is TIntHelper is going to extend the type TArray<Integer> instead of “array of Integer” (not to mention the boiler plate) so extra steps would have to be taking to make sure “array of T” type can find the helpers for TArray<T>. 

Not sure what the best solution is but here are the ones I can think of:

1) allow the helpers to use “array/set of T” syntax.
2) register helpers for both types.
3) perform an extra step to search helpers for “array of T” or “set of T” types.

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list