[fpc-pascal] Interface delegates and the implements property specifier
Ryan Joseph
genericptr at gmail.com
Tue Dec 24 02:47:01 CET 2019
> On Dec 23, 2019, at 7:57 PM, Ryan Joseph <genericptr at gmail.com> wrote:
>
> I never heard of "mixin" before but I'll study the wiki.
>
> I assume that the compiler team has decided multiple inheritance is a bad idea correct? Personally I don't have enough experience to know but I see there is a need to delegate work between classes and share a common namespace. I'm happy with any way to achieve that.
Here's what I got from reading. I saw this concept of "trait" from PHP (didn't even know it existed until now) and I think it would look like this in Pascal. From what I gather the "trait" is new kind of object that merely is injected into an object but it can't itself be allocated or assigned. Does that sound like what you had in mind?
program mixin;
type
TBrain = trait
procedure Eat;
procedure Fight;
end;
type
TPhysics = trait
x, y, z: float;
procedure Apply;
end;
type
TBase = class
use TPhysics, TRendering, TBrain;
end;
begin
end.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list