> On Jan 30, 2024, at 8:53 PM, Michael Van Canneyt via fpc-devel 
> <fpc-devel@lists.freepascal.org> wrote:
> 
> 'yes I do' what exactly ?
> 
> I thought I understood after your previous mail. Now I read your sentence as 
> an argument for not having a "final" at all, so this is again confusing for 
> me :/

I stepped in the middle of this and I didn't know methods could be final until 
now so maybe I'm confused to :). This is what we're talking out right?

type
  TAnimal = class
    procedure Fly; virtual;
  end;

  TBird = class
    procedure Fly; override;
  end;

  THawk = class
    procedure Fly; final;  // does it require override too or just final?
  end;


The idea is that now if you do:

procedure FlyHawk(hawk: THawk);
begin
  hawk.Fly;
end;

The compiler can just call THawk.Fly instead of using the VTable because it 
knows that no class in another unit overrode Fly after THawk. The same applies 
if the entire class is final too I would presume.

Regards,
Ryan Joseph

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to