[fpc-devel] Issue 20124: Error with static "direct field" properties

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Sep 1 19:42:41 CEST 2011


On 01 Sep 2011, at 19:21, Alexander Klenin wrote:

> On Fri, Sep 2, 2011 at 03:50, Jonas Maebe <jonas.maebe at elis.ugent.be> wrote:
>> 
>> On 01 Sep 2011, at 18:42, Alexander Klenin wrote:
>> 
>>> This leaves the first point, however. Why is it prohibited at all?
>> 
>> I think because class properties have several limitations that normal properties do not have: http://docwiki.embarcadero.com/RADStudio/en/Properties#Class_Properties
> 
> That is quite understandable. The question is why FPC limits *normal* properties
> by disallowing them to be implemented via static fields?

Because those limitations of class properties stem from the fact that those things (stored, default value, published) don't make sense in combination with class methods/fields. It would of course be possible to add special checking code to make sure that they are not used with regular properties if either the setter or the getter maps to a static class methods/fields (that's another thing: a property that mixes & matches like that should probably also be forbidden, so that's another special case that would have to be checked), but overall I think the current way is much cleaner and easier to implement/maintain. And it's Delphi-compatible to boot.


Jonas


More information about the fpc-devel mailing list