Am 29.01.2024 um 21:18 schrieb Michael Van Canneyt via fpc-devel:


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

Am 28.01.2024 um 12:14 schrieb Michael Van Canneyt via fpc-devel:



2)
Is there, or has there once been?
(found in the synedit highlighter)
  final

final comes after virtual/dynamic. Its supposed to stop you from overriding
a method. Which is a bit strange because then you should not declare it
virtual to begin with.

A person that overrides virtual methods does not always have control 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.

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

Reply via email to