[fpc-devel] Assigning to inherited property calls setter of the child class

Alexander Klenin klenin at gmail.com
Fri May 1 17:57:49 CEST 2009


On Sat, May 2, 2009 at 02:39, Mattias Gaertner
<nc-gaertnma at netcologne.de> wrote:
> On Sat, 2 May 2009 02:17:48 +1100
> Alexander Klenin <klenin at gmail.com> wrote:
>
>> Because this surprises developers and leads to bugs.
>> See the issue http://bugs.freepascal.org/view.php?id=13418
>> (linked from the discussed one) for a recent example.
>
> As Jonas already noted:
> 'That entirely depends on what you expect. "inherited property" now
> means "use the property as declared in the parent class", which in a sense is logical.'

Yes, I see. It is just in this particular case logic and intuition are
in conflict.

> You can create a bug report for the documentation that only mentions
> methods and maybe this is the reason for the confusion.
>
> For example:
[skipped example]

Although this is classic example of convoluted and bad code, it did convince me.
Including _both_ this and my examples in documentation is a good idea.
Is there a Mercurial mirror of FPC docs?

>> Alternative solution would be to issue a warning if
>> TInherited.SetP contains "inherited P := V" and SetP is virtual.
>
> -1

Why? Your example does not cover this.

-- 
Alexander S. Klenin



More information about the fpc-devel mailing list