comp.lang.ada
 help / color / mirror / Atom feed
From: "Mark Lundquist" <up.yerz@nospam.com>
Subject: Re: private properties of tagged records
Date: Fri, 08 Jun 2001 20:54:15 GMT
Date: 2001-06-08T20:54:15+00:00	[thread overview]
Message-ID: <XXaU6.131555$p33.2786953@news1.sttls1.wa.home.com> (raw)
In-Reply-To: 9frakn$5qr8r$1@ID-42131.news.dfncis.de


"Thomas Nebel" <thomas_nebel@gmx.de> wrote in message
news:9frakn$5qr8r$1@ID-42131.news.dfncis.de...
> Hi
>
> Is there a possibility to make properties of a tagged record "private"?;
> that you can
> access these properties only from a view functions, that have the
exclusive
> "right"
> to access them?
> Otherwise every function could change values in evrey record...
>
> Thomas

It looks like this:

        package Foo is

                type T is private;        -- This means clients of the
package can't see the full type
                                                 -- type definition

                procedure Do_Something (To : T);

        private

                type T is record          -- This is normal record
definition, but it "completes" the private
                    -- whatever...         -- type declaration above
                    --
                end record;

        end Foo;

Now, the full definition of T is visible only in the body of Foo.  So for
instance, procedure Do_Something can access the components of its parameter
To, but some other package that with's Foo cannot access to components of an
object of type T.

Note that:

1) A private type does not have to be a record type, it can be any kind of
type.
2) Ada has no notion of private vs. public components; either the type is
private or it isn't.

Does this help?

Mark Lundquist






  reply	other threads:[~2001-06-08 20:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-08 19:56 private properties of tagged records Thomas Nebel
2001-06-08 20:54 ` Mark Lundquist [this message]
2001-06-08 21:14   ` Ted Dennison
2001-06-09 17:41   ` Robert A Duff
2001-06-11 23:08     ` Georg Bauhaus
2001-06-09  7:44 ` Thomas Nebel
replies disabled

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