From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: How to stop inheritance in a good way?
Date: Wed, 15 Jan 2020 14:56:40 -0600
Date: 2020-01-15T14:56:40-06:00 [thread overview]
Message-ID: <qvnua8$v9l$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 755521b8-d0a8-41bd-b547-da1136e3b8e1@googlegroups.com
"reinert" <reinkor@gmail.com> wrote in message
news:755521b8-d0a8-41bd-b547-da1136e3b8e1@googlegroups.com...
...
> and I want object2_2_t *not* to inherit the function B (from type
> object1_t).
> I can make a dummy function B for object2_2_t (to override), but is it a
> more
>elegant/proper way? Or I here somehow break the concept of inheritance and
>enter a "dead end" ?
If you're only trying to inherit interfaces, then Dmitry's approach would
work. If you are trying to inherit implementations as well (in this case,
inheriting the implementation of function A for Object1_Type so you doesn't
have to write A again for Object2_Type), then there really isn't a solution
short of overriding with the B that raises an exception.
The reason that it has to be this way is that one can declare
objects/parameters of type Object1_Type'Class, and a dispatching call on B
is possible for such a type, and that call better have some body to execute.
OOP dogma (LSP) would generally consider that broken abstraction. (I'd say
that sometimes you have to do that to get the job done reasonably.)
Randy.
next prev parent reply other threads:[~2020-01-15 20:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-15 8:32 How to stop inheritance in a good way? reinert
2020-01-15 9:08 ` Dmitry A. Kazakov
2020-01-15 20:56 ` Randy Brukardt [this message]
2020-01-15 23:19 ` Jere
2020-01-17 9:48 ` reinert
2020-01-17 21:17 ` Optikos
2020-01-17 13:39 ` Shark8
2020-01-20 4:32 ` ric.wai88
2020-01-17 16:56 ` AdaMagica
2020-01-17 23:51 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox