> On Feb 10, 2021, at 7:47 PM, Martin Frb via fpc-pascal 
> <fpc-pascal@lists.freepascal.org> wrote:
> 
> In that case IIRC, it was said traits are not allowed constructors. Why?

Traits are meant to be a way to import fields/methods and is based off of 
"object" (so it's on the stack). This is also important for using properties to 
alias the imported fields. It's the same with subclassing, you don't need to 
manually allocate the super class because it's all one structure with a shared 
memory space. The idea is to make a viable alternative to inheritance in the 
simplest way possible.

> 
>> procedure TMyClass.DoThis;
>> begin
>>   // resolve the conflict by directly referencing the trait
>>   traitA.DoThis;
>> end;
>> 
>> 
> This we already can do. Write our own forwarder method.
> I understand it is for conflict resolution only. But see my example => as 
> soon as you need to repeat a trait with just a change in name, you always 
> need conflict resolution.
> IMHO, there are many traits that a class could need more than once.

I know it's not the most elegant but we need to keep this simple if there's 
going to be any chance of it even being considered. I will let the compiler 
team defer to this.

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