[fpc-devel] Modifiers...

Michael Van Canneyt michael at freepascal.org
Mon Jan 29 21:56:49 CET 2024



On Mon, 29 Jan 2024, Sven Barth via fpc-devel wrote:

>>> over whether the method had been declared as virtual.
>>
>> Hm. That makes no sense at all to me ?
>>
>> You normally add override only when you know the base class has virtual.
>> Otherwise, don't add virtual. The compiler will tell you if it was 
>> possible
>> or not.
>
> But that's the point: you *have* to add override. It will *always* be a 
> virtual method ("reintroduce" doesn't count, because that's essentially 
> the same as using a method with a completly different name). It's not in 
> the control of the user. With "final" the user has that control.
>
> Especially in application code (*not* library code) this can be useful, 
> especially if the compiler generates different code in both cases (as 
> said the compiler doesn't need to go through the VMT then if called with 
> the real class type which can be important in performance relevant code).
>
> Languages like C++, Java and C# all have these functionality as well and 
> only because *you* can't think of a legitimate use for it, doesn't mean 
> that no one can.

Please refrain from using things like '*you*' in your replies, 
it comes over as very agressive and authoritarian.

I didn't say I cannot think of a legitimate use. I said it does not make
sense to me, as in

"I don't understand what people try to accomplish with this modifier".

Unfortunately I still don't understand after your explanation what adding 'final' is supposed to accomplish. 
It may well be legitimate, but I have currently no opinion as I don't understand it.

Maybe an actual code example would be more enlightening.

That way I can also add it to the docs once I understand the intended use myself.

Michael.


More information about the fpc-devel mailing list