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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, T_FILL_THIS_FORM_SHORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d10596e187e90822 X-Google-Attributes: gid103376,public From: Hyman Rosen Subject: Re: Private Children Date: 1999/06/24 Message-ID: #1/1 X-Deja-AN: 493423124 Sender: hymie@calumny.jyacc.com References: <7klja3$c0p$1@nnrp1.deja.com> <376E70A5.F77E558D@averstar.com> <376E9EEB.322A3F39@averstar.com> <7kmoe4$o83@dfw-ixnews15.ix.netcom.com> <7kr4pc$bb9@dfw-ixnews15.ix.netcom.com> <7kra6p$t5h$1@remarQ.com> <7krq1m$m2@dfw-ixnews5.ix.netcom.com> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@panix.com X-Trace: news.panix.com 930241658 7444 209.49.126.226 (24 Jun 1999 16:27:38 GMT) Organization: PANIX Public Access Internet and UNIX, NYC Mime-Version: 1.0 User-Agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.3 NNTP-Posting-Date: 24 Jun 1999 16:27:38 GMT Newsgroups: comp.lang.ada Date: 1999-06-24T16:27:38+00:00 List-Id: Richard D Riehle writes: > In Mr. Freeman's Ada example, he assumes that the private part of > the package must contain a complete view of the data. That is exactly > the opposite of the example I posted earlier. which was -- package P is type T is tagged private; -- operations on T private type Item; type Item_Pointer is access all Item; type T is tagged record Data : Item_Pointer; -- a reference to hidden data end record; end P; > In Ada, we can declare an incomplete type, an access to that type, > enclose within a tagged record a value of the access type, and defer > the full description of the data until later. This is the essence of > an opaque type. Opaque types are convenient in both Ada and Modula-3 > because of their clear separation of interface module (package > specification) from implementation module (package body). This is > more difficult in Java, C++, and even Eiffel, as demonstrated in > Mr. Freeman's article. In C++ we can do the following. I'm not sure if I've duplicated the semantics you're aiming for, but I think I did. Unless I'm not understanding your intent, I don't see why my C++ is any more difficult than your Ada. class P { private: class Item; typedef Item *Item_Pointer; public: class T { public: // operations on T private: Item_Pointer Data; }; };