> On Feb 10, 2021, at 12:40 PM, Martin Frb via fpc-pascal 
> <fpc-pascal@lists.freepascal.org> wrote:
> 
> type
>   TSomeTrait = trait 
>   public 
>     procedure DoTraitFoo; 
>   end; 
> 
>   TSomeClass = class(TObject)
>   private
>     trait: TSomeTrait; // whatever syntax is used so that the trait is added
>   public
>     SomeVal: Integer;
>     procedure DoSome;
>     procedure Dispatch(var message); override;
>   end;

if it's the simple then just set a reference to TSomeClass inside of 
TSomeTrait. If the trait doesn't know anything about the implementor then you 
indeed need to use a dispatch table or something. Can't this be solved with 
existing features?

btw, I don't think we should model this based on PHP, I just gave that as an 
example. The Swift model is much more simple and does 99% of what you want. I 
think that's what we should do for Pascal also.

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