comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@notmyhomepage.invalid>
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
Date: 2019-02-14T19:04:06+01:00	[thread overview]
Message-ID: <q44ain$9qk$1@dont-email.me> (raw)
In-Reply-To: <5e42642d-3dd4-4c53-8b24-50bde70485f8@googlegroups.com>

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.



  parent reply	other threads:[~2019-02-14 18:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13 17:40 Mixing public and private member of a class. Dealing with what to hide and not Daniel Norber
2019-02-13 17:46 ` Daniel
2019-02-13 20:05 ` Dmitry A. Kazakov
2019-02-13 20:39 ` J-P. Rosen
2019-02-14  0:21 ` Jere
2019-02-14 18:04 ` G.B. [this message]
2019-02-22  8:42 ` Daniel
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox