[fpc-devel] Modifiers...

Hairy Pixels genericptr at gmail.com
Wed Jan 31 01:19:45 CET 2024



> On Jan 30, 2024, at 8:53 PM, Michael Van Canneyt via fpc-devel <fpc-devel at 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



More information about the fpc-devel mailing list