[fpc-pascal] Traits Proposal

Adriaan van Os fpc at microbizz.nl
Wed Feb 10 09:37:02 CET 2021


Michael Van Canneyt via fpc-pascal wrote:
> 
> 
> On Tue, 9 Feb 2021, Ryan Joseph via fpc-pascal wrote:
> 
>> We had talked about this some time ago and it's been rattling around 
>> in my brain so I wanted to write it down into a formal proposal where 
>> we can discuss it and hopefully agree upon a syntax. Everything is 
>> preliminary and tentative but this is a syntax which allows a 
>> "composition over inheritance" model, also known as "mix-ins" in some 
>> languages. That idea is similar to multiple inheritance except you 
>> have a concrete reference to the trait being implemented so you can 
>> resolve conflicts easily.
>>
>> Here's what I have so far. Please feel free to look at it and give any 
>> feedback.
>>
>> https://github.com/genericptr/freepascal/wiki/Traits-Proposal
> 
> In general, I am charmed by this idea.

I am, in whatever form it is implemented, also a proponent of the basic idea behind it, formulated 
on Ryan's  page as:

"Traits allow a "composition over inheritance" model which complement the existing single 
inheritance model introduced in Object Pascal. Traits are similar to multiple inheritance in 
languages such as C++ and Java, with the difference being an explicit reference to the class (or 
trait) which is being implemented."

Regards,

Adriaan van Os



More information about the fpc-pascal mailing list