[fpc-devel] Class property and virtual getter

Hans-Peter Diettrich DrDiettrich1 at aol.com
Thu Feb 27 15:35:28 CET 2014


Michael Van Canneyt schrieb:

>> So what's the special use of a *class* property? If it exists for 
>> Delphi compatibility only, why then is it handled differently from 
>> "property"?
> 
> The reason is explained in the upcoming docs.
> 
> Namely: a static method cannot be overridden.

Sure, but virtual methods (including class methods) can be overridden.

> The class property is part 
> of this particular class, and descendent classes should not be able to 
> override it's behaviour.

A static class method can call another virtual class method, so this 
protection looks very artifical to me.


BTW Delphi XE allows to call a virtual class method, but when called 
from a static class method it calls it like a static method, overrides 
are simply ignored. Calling the same method directly honors overrides.

Also "self" is no more known inside class methods in XE. In D7 it was 
the class type instead of the instance pointer. Thus a too restrictive 
compiler, geared towards compatibilitiy with *new* Delphi versions, may 
break existing code.

DoDi




More information about the fpc-devel mailing list