[fpc-devel] Question on interface inheritance...
Martin Frb
lazarus at mfriebe.de
Sun Feb 1 16:57:06 CET 2026
On 01/02/2026 16:50, Martin Frb via fpc-devel wrote:
>
> Ok, lets see what other think / it wont help for now either, since it
> wont work with the current compiler.
>
>
> But I do think that (other than the work for the compiler devs) it
> would be a neat feature.
And as I said it comes in useful if you have a generic...
I wanted
interface BaseList
function IntfBaseItem
interface FooList(BaseList)
function IntfFooItem (inherits BaseItem)
generic ListFeature<_LIST: BaseList, _ITEM: BaseItem> = class
procedure DoSomething(AnItem: _Item); virtual;
procedure DoWork....;
end;
DoWork would go over the list, and for the correct items call DoSomething.
DoSomeThing needs the correct class, so if I specialize this as base, my
new class
type TBar = class(specialize ListFeature<FooList, FooItem>)
procedure DoSomething(AnItem: FooItem); override;
end
can access all the stuff that FooItem has.
More information about the fpc-devel
mailing list