[fpc-pascal] Traits Proposal

Ryan Joseph genericptr at gmail.com
Sun Feb 14 17:25:37 CET 2021



> On Feb 14, 2021, at 9:16 AM, Michael Van Canneyt via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> I didn't propose using an interface; For me the
> 
> property Test: TTestImpl read fTest implements TTestIimpl;
> 
> Where TTestImpl is an object (tp style) or advanced record (delphi style) is ample.

That was directly more at Sven. I like the idea of a "default property" and Sven appears to agree, but there's some debate on how this should be achieved. In fact we already had another long thread on default properties some years ago but it got derailed due to the implication of using default properties with all types.

Maybe what we really want is a default property for struct types which does strict name collision checking?

property Test: TSomeRec read fTest; default;

That's a simple idea which is easy to reason about, doesn't require any new syntax and is easy to implement (more on that if we get that far).

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list