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!news4.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Possible Ada deficiency? References: <1104516913.718856.94090@z14g2000cwz.googlegroups.com> In-Reply-To: <1104516913.718856.94090@z14g2000cwz.googlegroups.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 31 Dec 2004 19:12:14 GMT NNTP-Posting-Host: 4.240.168.249 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1104520334 4.240.168.249 (Fri, 31 Dec 2004 11:12:14 PST) NNTP-Posting-Date: Fri, 31 Dec 2004 11:12:14 PST Xref: g2news1.google.com comp.lang.ada:7355 Date: 2004-12-31T19:12:14+00:00 List-Id: danmcleran@hotmail.com wrote: > 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. You're confusing C++ classes with Ada packages. In C++, classes serve a multitude of purposes, including encapsulation, information hiding, type extension, and dynamic dispatching. In Ada, encapsulation, name space control, and information hiding are handled by packages. Type extension and dispatching are handled by tagged types. Private components in C++ prevent the components from being visible to derived types. This is also possible in Ada: package P is type T is tagged private; procedure Op (A : in out T); private -- P type T is tagged record I : Integer := 0; end record; end P; with P; package Q is type T is new P.T with record F : Float := 0.0; end record; procedure Op_2 (A : in out T); end Q; package body Q is procedure Op_2 (A : in out T) is -- null; begin -- Op_2 A.I := 2; -- Illegal. end Op_2; end Q; Child packages in Ada provide the equivalent of friends in C++; thus, the private part of a package is akin to protected in C++, with the package body corresponding to C++'s private. -- Jeff Carter "Ada has made you lazy and careless. You can write programs in C that are just as safe by the simple application of super-human diligence." E. Robert Tisdale 72