comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Mixing public and private member of a class. Dealing with what to hide and not
Date: Wed, 13 Feb 2019 21:05:30 +0100
Date: 2019-02-13T21:05:30+01:00	[thread overview]
Message-ID: <q41tab$1vak$1@gioia.aioe.org> (raw)
In-Reply-To: 5e42642d-3dd4-4c53-8b24-50bde70485f8@googlegroups.com

On 2019-02-13 18:40, Daniel Norber wrote:
> Sorry for my bad english.
> I'm having big troubles in how Ada deals mixing public and private member of a class.

Well, this one of sore spots in Ada where information hiding does not 
work well. Anyway, try this:

    type T is abstract tagged record -- This is a helper type, no
       Public : Integer;             -- instances of
    end record;
    type S is new T with private; -- This is the interface type
private
    type S is new T with record
       Secret : Integer;
    end record;

P.S. In many cases you do not expose members, only operations.

P.P.S. Discriminants can be misused as read-only members:

    type S (Public : Integer) is new T with private;
private
    type S (Public : Integer) is new T with record
       Secret : Integer;
    end record;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2019-02-13 20:05 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 [this message]
2019-02-13 20:39 ` J-P. Rosen
2019-02-14  0:21 ` Jere
2019-02-14 18:04 ` G.B.
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