comp.lang.ada
 help / color / mirror / Atom feed
* private properties of tagged records
@ 2001-06-08 19:56 Thomas Nebel
  2001-06-08 20:54 ` Mark Lundquist
  2001-06-09  7:44 ` Thomas Nebel
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Nebel @ 2001-06-08 19:56 UTC (permalink / raw)


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






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: private properties of tagged records
  2001-06-08 19:56 private properties of tagged records Thomas Nebel
@ 2001-06-08 20:54 ` Mark Lundquist
  2001-06-08 21:14   ` Ted Dennison
  2001-06-09 17:41   ` Robert A Duff
  2001-06-09  7:44 ` Thomas Nebel
  1 sibling, 2 replies; 6+ messages in thread
From: Mark Lundquist @ 2001-06-08 20:54 UTC (permalink / raw)



"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






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: private properties of tagged records
  2001-06-08 20:54 ` Mark Lundquist
@ 2001-06-08 21:14   ` Ted Dennison
  2001-06-09 17:41   ` Robert A Duff
  1 sibling, 0 replies; 6+ messages in thread
From: Ted Dennison @ 2001-06-08 21:14 UTC (permalink / raw)


In article <XXaU6.131555$p33.2786953@news1.sttls1.wa.home.com>, Mark Lundquist
says...
>2) Ada has no notion of private vs. public components; either the type is
>private or it isn't.

However, a public type *can* contain components whose *type* is private...

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: private properties of tagged records
  2001-06-08 19:56 private properties of tagged records Thomas Nebel
  2001-06-08 20:54 ` Mark Lundquist
@ 2001-06-09  7:44 ` Thomas Nebel
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Nebel @ 2001-06-09  7:44 UTC (permalink / raw)


Thank you !

It works.


Thomas





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: private properties of tagged records
  2001-06-08 20:54 ` Mark Lundquist
  2001-06-08 21:14   ` Ted Dennison
@ 2001-06-09 17:41   ` Robert A Duff
  2001-06-11 23:08     ` Georg Bauhaus
  1 sibling, 1 reply; 6+ messages in thread
From: Robert A Duff @ 2001-06-09 17:41 UTC (permalink / raw)


"Mark Lundquist" <up.yerz@nospam.com> writes:

> 2) Ada has no notion of private vs. public components; either the type is
> private or it isn't.

Right.  If you want both, you can do something like this:

    package P is
        type T_Visible is abstract new ... with
            record
                ... -- visible stuff
            end record;
        type T is new T_Visible with private;
        ...
    private
        type T is new T_Visible with
            record
                ... -- private stuff
            end record;
    end P;

- Bob



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: private properties of tagged records
  2001-06-09 17:41   ` Robert A Duff
@ 2001-06-11 23:08     ` Georg Bauhaus
  0 siblings, 0 replies; 6+ messages in thread
From: Georg Bauhaus @ 2001-06-11 23:08 UTC (permalink / raw)


Robert A Duff <bobduff@world.std.com> wrote:
: 
: Right.  If you want both, you can do something like this:
: 
...
:        type T_Visible is abstract new ... with
:            record
:                ... -- visible stuff
:            end record;
:        type T is new T_Visible with private;
...

Is this also an opportunity to think about record discriminants,
and limited records?

Just curious.

--Georg
---
Microsoft Windows--a fresh perspective on information hiding



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-06-11 23:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-08 19:56 private properties of tagged records Thomas Nebel
2001-06-08 20:54 ` Mark Lundquist
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

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