[fpc-pascal] Traits Proposal

Ryan Joseph genericptr at gmail.com
Wed Feb 10 17:52:45 CET 2021



> On Feb 10, 2021, at 9:06 AM, Michael Van Canneyt <michael at freepascal.org> wrote:
> 
> You said it yourself: internally it will just be an object. Just make it formally so.
> 
> I also think the argument of reusing existing objects deserves consideration.

Is it strange that there are extra things in the object which aren't related to the trait? You could declare destructors/constructors and maybe function modifiers that don't make sense in modern code. I don't have a strong argument I guess except it feels clean to start with a fresh slate. I'm also assuming that during development we'll find problems with how to handle feature X of objects which are conflicting somehow and it would be easier to have a new type to resolve this. I'll wait to hear from others.

Still, the biggest hurdle is getting any acceptance from the compiler team. I really don't like the interface delegation pattern (from Delphi?) because it doesn't help with namespaces but as Sven suggested this should be good enough for us. Traits are easy to understand and implement but the interface delegation requires tons of boiler plate and you still need to subscript into classes instead of getting a nice unified namespace.

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list