[fpc-devel] Re: Class field reordering

Michael Van Canneyt michael at freepascal.org
Sun Jul 22 10:39:58 CEST 2012



On Sat, 21 Jul 2012, Florian Klämpfl wrote:

> Am 21.07.2012 23:06, schrieb Ivanko B:
>> No, just reorder the fields so that they can be properly $IFDEFed as
>> protected for nonLAZARUS and left (private) as is otherwise.
>
> Why should lazarus people have less chances to mess with private fields?
> Either we make them public for all or for nobody. Of course, then
> everybody has to take care of the fact that users might mess with these
> fields.

Which is exactly why we will not do this.

The base classes expose a well-defined API. 
This API is a contract you make with the developers of descendent classes.

Some fields are kept private to ensure that the terms of the contract 
can be met. Making them public/protected means that the terms of the 
contract can be broken by Developer A, when the code of developer B 
depends on the terms being rigorously enforced, and his code can go 
very wrong.

This is of course not so for all private fields, which is why I ask 
for reasons, so I can decide for each field what can or cannot be done.

And, if possible, alternative solutions will be presented if they can be found.
But for that, I need to know in detail what the problem is in the first place.

Michael.


More information about the fpc-devel mailing list