> On Dec 23, 2019, at 7:57 PM, Ryan Joseph <generic...@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

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

Reply via email to