comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: overriding in private part
Date: Fri, 3 Oct 2008 08:54:47 -0700 (PDT)
Date: 2008-10-03T08:54:47-07:00	[thread overview]
Message-ID: <bbd02ce6-572f-4af0-9284-228c71c95e0d@d70g2000hsc.googlegroups.com> (raw)
In-Reply-To: hkj5r014m090$.8csbvkmmfqt4$.dlg@40tude.net

On Oct 3, 1:52 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:

> > But
> > since "overriding" has been added, you should just use it, and it will
> > solve the problem.
>
> Unfortunately it does not.

I shouldn't have said "solve".  It *partially* solves the problem, in
that if the programmers use "overriding" and "not overriding"
consistently on everything, it won't let you write a program that has
an unexpected result of the sort Maxim ran into.  Of course, having
the compiler tell you your program is illegal isn't really a full
solution when the language should be letting you do what you need to
do, but it's a heck of a lot better than accepting your program and
doing the wrong thing.


> The programmer desired to override P2, and this
> is impossible to do, because there is a type in between which effectively
> *hides* the operation in all packages, regardless their visibility.
> Further, this behavior changes when the offending type is derived in A1
> rather than in A1.A2. In that case A1.A3 would be able to override P2.
>
> This is obviously broken to me.

I think this is a good point, and I'm trying to think of a possible
solution.  The small stumbling block is that it's possible to declare
a private extension in a package Package_1

   type T1 is new T with private;

and then, in the private part of Package_1:

   type T1 is new T2 with ...

where T2 is a child of T.  Clearly, any *new* operations that were
declared for T2 but not for T shouldn't be visible, or overridable, by
any package that can't see into the private part of Package_1.  But
that just means that any proposed change would have to be written a
bit more carefully; it's not an insurmountable obstacle.

Anyway, I'm thinking about how this could be fixed.

                               -- Adam



  reply	other threads:[~2008-10-03 15:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-02 15:49 overriding in private part Maxim Reznik
2008-10-02 16:42 ` Adam Beneschan
2008-10-03  8:52   ` Dmitry A. Kazakov
2008-10-03 15:54     ` Adam Beneschan [this message]
2008-10-03 20:29       ` Robert A Duff
2008-10-04  2:28         ` Randy Brukardt
2008-10-04 19:47           ` Robert A Duff
2008-10-05  7:35             ` Dmitry A. Kazakov
2008-10-05 19:57               ` Robert A Duff
2008-10-06  8:50                 ` Dmitry A. Kazakov
2008-10-06 23:32                   ` Randy Brukardt
2008-10-05 11:46             ` stefan-lucks
2008-10-05 20:08               ` Robert A Duff
2008-10-06 23:39                 ` Randy Brukardt
2008-10-02 23:17 ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox