From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b8b8a54001adc4d2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Possible Ada deficiency? Date: Sat, 1 Jan 2005 12:43:56 +0100 Organization: cbb software GmbH Message-ID: References: <1104516913.718856.94090@z14g2000cwz.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: individual.net OF4LW9zNbF1TODWdYB+HKAhIO7zqr2dCg49TuR/OXBwYQ9RrQ= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:7368 Date: 2005-01-01T12:43:56+01:00 List-Id: 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