comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Possible Ada deficiency?
Date: Sat, 1 Jan 2005 12:43:56 +0100
Date: 2005-01-01T12:43:56+01:00	[thread overview]
Message-ID: <p42feqrui3cs.n1bi6hz47hux$.dlg@40tude.net> (raw)
In-Reply-To: 1104516913.718856.94090@z14g2000cwz.googlegroups.com

On 31 Dec 2004 10:15:13 -0800, danmcleran@hotmail.com wrote:

> I would like to know if anyone else thinks that the inability to hide
> private information from child packages is a deficiency in Ada95. I am
> discussing ways to do this on another thread, (See Private area and
> child packages), but it seems wrong that one has to go through a bunch
> of machinations to do something like this. Wouldn't a language
> construct for this be advantageous?
> 
> In C++ and Java, no private data can be seen by child classes. I think
> that Ada would benefit from extending its information hiding
> capabilities by allowing a package writer to conceal type information
> from child packages.
> 
> What if Ada had a keyword, I've chosen 'concealed' for the sake of
> discussion, to indicate that the implementation of a type was not
> visible to the outside world (including child packages). Something like
> this:
> 
> --This is not Ada!
> 
> package Some_Package is
> type Not_So_Secret_Type is private;   -- Child packages can see the
> details
> type Super_Secret_Type  is concealed; -- Hidden from everyone
> private
> --child packages have full visibility
> concealed
> --not even child packages can see here
> end Some_Package;

I do not think it is a deficiency. What you want is just C++'s private.
Ada's private is like C++'s protected.

OK, what is actually the use of C++'s private? It is used to declare
implementation-specific members, which cannot be accessed by anyone except
the owner, i.e. by the class implementation. But that breaks implementation
hiding concept! A private part of implementation gets exposed in a class
definition. Well, it might be inaccessible, but it is still there and
visible to the code reader. [S]he might unintentionally use it, not
directly but you know there are many ways to play tricks. So to me the idea
of C++'s private is altogether wrong.

Now let's return to Ada. There you need not to expose implementation in a
package specification. If you need a C++-like member function, you never
declare it there. You rather move it into the package body. If that gets
too large, you make a separate body or a separate nested package, but again
declared in the package body (*). So Ada provides better information hiding
here. Where your critique might be right is that the above is not true for
data members. It is not easy to hide them.

Anyway, in my view the only right way to hide something is in the body.
From this point of view your proposal would be a step in wrong direction.

----------
* Note two mechanisms to provide implementations in Ada. Child packages are
for implementation "en large", when the designer of an interface will not
implement it now and here. For a tighter local implementation one should
always use the body. That can be organized in a way equivalent to child
packages. Analogous objects here are packages nested in the body. A nested
package body can be separate.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2005-01-01 11:43 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-31 18:15 Possible Ada deficiency? danmcleran
2004-12-31 19:12 ` Jeffrey Carter
2005-01-01  1:52   ` danmcleran
2005-01-01  2:37     ` Jeffrey Carter
2005-01-01  2:02   ` danmcleran
2005-01-01 14:11     ` Martin Krischik
2005-01-01 15:27       ` danmcleran
2005-01-02 17:49         ` Martin Krischik
2005-01-01 15:30     ` Stephen Leake
2005-01-01 15:57       ` danmcleran
2005-01-03 23:37         ` Randy Brukardt
2005-01-07 17:26           ` Nick Roberts
2005-01-07 18:26             ` danmcleran
2005-01-07 21:32             ` Randy Brukardt
2005-01-08  3:56               ` Nick Roberts
2005-01-08 18:15                 ` Robert A Duff
2005-01-08 19:11                   ` Jeffrey Carter
2005-01-08 20:03                     ` Robert A Duff
2005-01-09  3:40                       ` Jeffrey Carter
2005-01-09 17:30                         ` Robert A Duff
2005-01-09 19:24                           ` Jeffrey Carter
2005-01-09 21:56                           ` Nick Roberts
2005-01-10 13:47                             ` Dmitry A. Kazakov
2005-01-10 16:46                               ` Duncan Sands
2005-01-10 17:58                                 ` Pascal Obry
2005-01-10 18:45                                   ` Dmitry A. Kazakov
2005-01-10 19:44                                     ` Pascal Obry
2005-01-11 10:05                                       ` Dmitry A. Kazakov
2005-01-11  7:24                                     ` Vinzent 'Gadget' Hoefler
2005-01-11  9:48                                       ` Dmitry A. Kazakov
2005-01-11 13:57                                         ` Vinzent 'Gadget' Hoefler
2005-01-11 21:52                                           ` Robert A Duff
2005-01-12 11:22                                           ` Dmitry A. Kazakov
2005-01-09 17:23                   ` danmcleran
2005-01-09 17:46                     ` Robert A Duff
2005-01-10  3:05                       ` danmcleran
2005-01-09 18:41                   ` Nick Roberts
2005-01-09 19:06                     ` Martin Krischik
2005-01-09 20:10                     ` Robert A Duff
2005-01-09 20:15                     ` Robert A Duff
2005-01-11 14:13                       ` Possible Ada deficiency? (goto) Peter Hermann
2005-01-11 14:54                         ` Nick Roberts
2005-01-11 22:15                         ` Robert A Duff
2005-01-12 10:17                           ` Peter Hermann
2005-01-15 17:34                             ` Robert A Duff
2005-01-15 17:58                               ` Dmitry A. Kazakov
2005-01-15 19:34                                 ` Robert A Duff
2005-01-10 20:15                   ` Possible Ada deficiency? Randy Brukardt
2005-01-10 21:51                     ` Robert A Duff
2005-01-11 20:23                       ` Randy Brukardt
2005-01-11 21:24                         ` Robert A Duff
2005-01-12 19:57                           ` Randy Brukardt
2005-01-02 15:51       ` Adrian Hoe
2005-01-04 16:06       ` Peter Hermann
2005-01-01 23:36     ` tmoran
2005-01-02  3:38       ` danmcleran
2004-12-31 19:16 ` Martin Dowie
2005-01-01  2:32   ` Jeffrey Carter
2004-12-31 23:23 ` Nick Roberts
2005-01-01  1:56   ` danmcleran
2005-01-01 11:43 ` Dmitry A. Kazakov [this message]
2005-01-01 15:46   ` danmcleran
2005-01-01 17:58     ` Larry Kilgallen
2005-01-01 19:43       ` danmcleran
2005-01-02  0:36         ` Ed Falis
2005-01-02  3:36           ` danmcleran
2005-01-02 15:53             ` Ed Falis
2005-01-07 18:31               ` danmcleran
2005-01-07 18:44                 ` Pascal Obry
2005-01-07 19:29                   ` danmcleran
2005-01-07 21:28                     ` Pascal Obry
2005-01-01 23:28   ` danmcleran
2005-01-02 10:26     ` Dmitry A. Kazakov
2005-01-02 15:51       ` danmcleran
2005-01-03 23:48     ` Randy Brukardt
2005-01-01 14:06 ` Martin Krischik
2005-01-01 15:53   ` danmcleran
2005-01-07 21:33 ` Robert A Duff
2005-01-09 17:15   ` danmcleran
2005-01-09 17:38     ` Robert A Duff
2005-01-10  3:16       ` danmcleran
2005-01-09 18:41     ` Martin Dowie
2005-01-10  3:18       ` danmcleran
2005-01-10 20:32         ` Randy Brukardt
2005-01-10 21:42           ` danmcleran
2005-01-10 21:36         ` Robert A Duff
2005-01-10 21:44           ` danmcleran
2005-01-09 19:01     ` Jeffrey Carter
2005-01-10  3:20       ` danmcleran
2005-01-10 22:16         ` Robert A Duff
2005-01-10 22:29           ` danmcleran
2005-01-11 20:12             ` Georg Bauhaus
2005-01-11 20:30               ` danmcleran
2005-01-11 21:44               ` Robert A Duff
2005-01-11  0:06           ` Jeffrey Carter
2005-01-11  0:46             ` Robert A Duff
2005-01-11 20:37           ` danmcleran
2005-01-11 21:08             ` Robert A Duff
2005-01-17  4:40 ` Tucker
2005-01-18 13:46   ` danmcleran
2005-01-18 21:29     ` Nick Roberts
2005-01-24 17:23   ` danmcleran
  -- strict thread matches above, loose matches on Subject: below --
2004-12-31 19:06 danmcleran
replies disabled

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