[fpc-devel] Assigning to inherited property calls setter of the child class
nc-gaertnma at netcologne.de
Fri May 1 18:16:09 CEST 2009
On Sat, 2 May 2009 02:57:49 +1100
Alexander Klenin <klenin at gmail.com> wrote:
> 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?
Will you create the bug report?
> >> 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.
Because properties have nothing to do with methods.
It would be nice it FPC can give a warning/hint if 'inherited' is used
and there is no such member in the current class. Because in this case
the 'inherited' is useless and the programmer probably intended
something other. This warning/hint can be given for all members -
properties, methods and variables.
More information about the fpc-devel