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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: Mixing public and private member of a class. Dealing with what to hide and not Date: Thu, 14 Feb 2019 19:04:06 +0100 Organization: A noiseless patient Spider Message-ID: References: <5e42642d-3dd4-4c53-8b24-50bde70485f8@googlegroups.com> Reply-To: nonlegitur@notmyhomepage.de Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 14 Feb 2019 18:04:07 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="2f622eea5b5d48b1c5bfd8c9c9ebf8ee"; logging-data="10068"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/foghgwWM7YRJ4iM86BeXE8Ne/LoXNqbk=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 Cancel-Lock: sha1:A1GsWdrxei8s5xMH6MyM8tXH/PM= In-Reply-To: <5e42642d-3dd4-4c53-8b24-50bde70485f8@googlegroups.com> Content-Language: de-DE Xref: reader01.eternal-september.org comp.lang.ada:55518 Date: 2019-02-14T19:04:06+01:00 List-Id: On 13.02.19 18:40, Daniel Norber wrote: > I'm having big troubles in how Ada deals mixing public and private member of a class. The easiest way out is to always structure Ada types as if you'd write class AdaStyle { private: int data; T0* thing; public: int query(...) const; // involves `data` virtual void merge(const T0& other); }; I.e., as others have said, just don't make any data compotent publicly accessible. A possible exception might be a read-only "initialization parameter" such as is offered by a discriminant: type Thing (Capacity : Natural) is private; type Pixel (Color : RGB) is limited private; These can freeze numbers of parts of variants of (record) types. Some suggest to also consider composition as a possible alternative to extension. So does Stroustrup, IIRC.