> On Feb 18, 2021, at 11:30 PM, Sven Barth <pascaldra...@googlemail.com> wrote:
> 
> The only thing that will not work and which will continue not to work is that 
> m_circle.Draw will not be called if you access the TMyShape through a 
> TShape.Draw call. For that one needs to use an explicit declaration:
> 
> === code begin ===
> 
> type
>   TMyShape = class(TShape, ICircle)
>   private
>     m_circle: TCircle;
>   public
>     procedure ICircle.Draw = Draw;
>     property Circle: TCircle read m_circle implements ICircle;
>     procedure Draw; override;
>   end;
> 
> procedure TMyShape.Draw;
> begin
>   m_circle.Draw;
> end;
> 
> === code end ===


So the method resolution doesn't actually change the VMT table of the class, 
just the interface? That's unfortunate because being able to affect the VMT by 
method resolution would open up a lot of possibilities for polymorphism using 
composition. Maybe writing wrapper functions is good enough for this. Not sure, 
I need to do some research into old code and explore things a bit more.


I just realized another potential problem. If we use the "default" keyword that 
means there could be multiple "defaults" unless we limit the property to 1 per 
class, which would kind of defeat the purpose of the feature (like the issue we 
had with helpers and made multi-helpers for).

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