[fpc-pascal] Traits Proposal

Sven Barth pascaldragon at googlemail.com
Thu Feb 18 22:42:28 CET 2021


Am 18.02.2021 um 20:33 schrieb Martin Frb via fpc-pascal:
> could be written as
>
>   generic TTrait<T> = class(T)
>     procedure Bar;
>   end;
>
>   TMyFoo = class(specialize TTrait<TFooBase>)
>      procedure Foo;
>   end;
>
> Of course that can get out of hand, if you want to include many traits.

You need to constrain T as a TObject, then it works.

Regards,
Sven


More information about the fpc-pascal mailing list