[fpc-devel] Class property and virtual getter

Hans-Peter Diettrich DrDiettrich1 at aol.com
Fri Feb 28 02:12:58 CET 2014


Jonas Maebe schrieb:

>> Error: Only class methods, class properties and class variables can be
>> referred with class references
> 
> You have to declare an instance and then call its property. You don't 
> have to instantiate the instance if the property maps to a class method.
> 
>> Technically there's some obstacle to allow such construct?

As long as a method doesn't use Self, directly or implicitly, the 
absence of an object reference does not cause problems.

> Class properties should be accessible from within static class methods. 
> Having them accessible depending on the getter/setter they use (static 
> or not) would break orthogonality (the visibility/usability must depend 
> on the interface, not on the implementation of the interface).

This would mean that in legacy code the non-virtual methods have to be 
separated now, into non-virtual, static, class and static class methods, 
in order to keep the code compiling?

> Non-static class methods cannot be called from static class methods 
> because you don't know the original class type that was used to call it 
> (and hence this could have unexpected results).

Does this mean that the new static class methods don't have an Self 
parameter?

DoDi




More information about the fpc-devel mailing list