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=0.6 required=5.0 tests=BAYES_00,FROM_WORDY, 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,23cf9f1e93744eed X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-08-01 14:39:39 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newshub.sdsu.edu!news-hog.berkeley.edu!ucberkeley!tethys.csu.net!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Need advice re package organization. Date: 01 Aug 2003 17:33:30 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <3F228F3B.9020203@attbi.com> <3F22F9E9.3040307@attbi.com> <5jn9ivoetll1fu2avn9hmjj6aaa7q7pmjn@4ax.com> <7GfWa.5186$mv6.907516@news20.bellglobal.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1059773693 5055 128.183.235.92 (1 Aug 2003 21:34:53 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 1 Aug 2003 21:34:53 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Xref: archiver1.google.com comp.lang.ada:41135 Date: 2003-08-01T21:34:53+00:00 List-Id: "Randy Brukardt" writes: > "Warren W. Gay VE3WWG" wrote in message > news:7GfWa.5186$mv6.907516@news20.bellglobal.com... > > > > > We're talking about protected access of classes (C++). > > As I said above, I don't know C++ well enough to know exactly what it is > that you are proposing. And in any case, Ada is not C++. Please describe > what you want in Ada terms, with Ada syntax. Perhaps I can help, since I beleive I do know C++ and Ada well enough :). The C++ notions of public, protected, and private member functions do not map one-to-one into Ada, but they map fairly well according to the following scheme (data members below): C++ Ada public public part of package spec protected private part of package spec private package body C++ can make the same distinctions among data members of a record type. For example: class Foo { public: int A; protected: int B; private: int C; } A is visible to all children and clients of Foo; B is visible to children of Foo; C is only visible within Foo. To achieve the same visibility in Ada, we need to break up the record type: package Foo_Package is type Protected_Foo is private; type Foo is record A : Integer; Protected_Stuff : Protected_Foo; end record; private type Private_Foo; type Private_Foo_Access is access Private_Foo; type Protected_Foo is record B : integer; Private_Stuff : Private_Foo_Access; end record; end Foo_Package; package body Foo_Package is type Private_Foo is record C : Integer; end type; end Foo_Package; If you are comming from a C++ background, the Ada approach seems contorted. From an Ada point of view, the C++ approach seems simplistic :). I believe I have seen proposals that allow a single Ada record to have public and private parts, something like: package Foo_Package is type Foo is record A : Integer; end record with private; private type Foo is record with private B : integer; end record; end Foo_Package; But that only achieves the C++ protected visibility, not the private. -- -- Stephe