digitalmars.D.learn - Final class
- Daniel Kozak (2/2) Jul 11 2013 Are all methods in final class non-virtual or must be explicity
- Jonathan M Davis (11/13) Jul 11 2013 They're virtual if they override base class functions, but they're defin...
- Daniel Kozak (2/23) Jul 11 2013 Thanks
Are all methods in final class non-virtual or must be explicity marked as a final too?
Jul 11 2013
On Friday, July 12, 2013 07:03:07 Daniel Kozak wrote:Are all methods in final class non-virtual or must be explicity marked as a final too?They're virtual if they override base class functions, but they're definitely all final. So, the compiler _should_ optimize the functions in a final class which don't override anything so that they're non-virtual. However, I'm not sure that there's actually any guarantee that final methods which don't override anything will actually be made non-virtual. It's an optimization based on the fact that the compiler can determine that it can be made non- virtual rather than it explicitly being made non-virtual by the programmer, so the compiler might not do it. It _should_, but I'm not sure that it's guaranteed to. - Jonathan M Davis
Jul 11 2013
On Friday, 12 July 2013 at 05:13:44 UTC, Jonathan M Davis wrote:On Friday, July 12, 2013 07:03:07 Daniel Kozak wrote:ThanksAre all methods in final class non-virtual or must be explicity marked as a final too?They're virtual if they override base class functions, but they're definitely all final. So, the compiler _should_ optimize the functions in a final class which don't override anything so that they're non-virtual. However, I'm not sure that there's actually any guarantee that final methods which don't override anything will actually be made non-virtual. It's an optimization based on the fact that the compiler can determine that it can be made non- virtual rather than it explicitly being made non-virtual by the programmer, so the compiler might not do it. It _should_, but I'm not sure that it's guaranteed to. - Jonathan M Davis
Jul 11 2013