> On Feb 10, 2021, at 2:42 PM, Ryan Joseph <[email protected]> wrote:
>
> We should keep it as simple as possible imo.
It's not as elegant as other ideas we may think of but I think it's good enough
to let users write boilerplate methods to resolve naming conflicts. We don't
need to introduce new syntax or concepts. This is the power of traits vs
multiple inheritance. We get the shared namespace like normal OOP inheritance
but have full control over any conflicts that arise by mixing in traits.
====================
type
TTraitA = trait
procedure DoThis;
end;
TTraitB = trait
procedure DoThis;
end;
type
TMyClass = class
private
property traitA: TTraitA implements _traitA;
property traitB: TTraitB implements _traitB;
public
// DoThis now hides traitB.DoThis like it would in normal Object Pascal
procedure DoThis;
end;
procedure TMyClass.DoThis;
begin
// resolve the conflict by directly referencing the trait
traitA.DoThis;
end;
Regards,
Ryan Joseph
_______________________________________________
fpc-pascal maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal