On Mon, 25 Apr 2022 10:15:26 +0700
Hairy Pixels via fpc-pascal <fpc-pascal@lists.freepascal.org> wrote:

>[...]
> For the case of types I understand we must specialize because we’re
> creating a new type each time and there is nothing to infer from the
> context, but for functions it’s backwards, that is we know the types
> being used, we just need to choose the right function based on those
> types.

IMO the important difference is that alias types already safes most
inline specializations.
There is no alias for generic functions, which is why implicit function
specialization is so handy.

 
>[...]
> type
>   generic TArrayHelper<T> = type helper for array of T
>     procedure Add(value: T);
>   end;
> 
> var
>   a: array of integer;
> begin
>   a.Add(1);  // specialize TArrayHelper<Integer> since the compiler
> clearly knows the type used is Integer. end.

IMO that is only useful with modeswitch multihelpers.

All these modeswitches makes it harder to learn Pascal.

Mattias
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to