comp.lang.ada
 help / color / mirror / Atom feed
From: "Mark Lundquist" <up.yerz@nospam.com>
Subject: Re: Re[2]: Limited Type Access - Again
Date: Tue, 30 Oct 2001 17:10:36 GMT
Date: 2001-10-30T17:10:36+00:00	[thread overview]
Message-ID: <gaBD7.1002$Fm5.605232@news1.sttln1.wa.home.com> (raw)
In-Reply-To: mailman.1004394165.6249.comp.lang.ada@ada.eu.org


<ANH_VO@udlp.com> wrote in message
news:mailman.1004394165.6249.comp.lang.ada@ada.eu.org...
> If equality and assignment are allowed in this case, then it is the back
door
> for comparing and assigning objects of limited type such as task type and
> projected type.

No, it's not a back door!

There's no assignment for limited types.  In fact, that's the definition of
"limited type" -- a type for which there is no assignment.

How about this... supply a minimal complete example of how you think this
can happen due  to an access-to-limited type being itself non-limited, with
a comment saying "HERE IS WHERE IT HAPPENS" at the relevant line, then we
can walk through it and show you that it's really not happening (or more
likely, you'll see it yourself when you try this exercise :-)

> I think this door should be locked. In addition, comparing or
> assignment two objects of a task type does not make sense.

Assignment certainly doesn't, which is why tasks are limited.  But there's
no "back door".

> In fact, the language
> prohibits two objects of a limited type from being compared or assigned.
This is
> the reason why equality and assignment of a limited type are prohibited.

True for assignment (by definition)... but "=" is not *prohibited*... there
just is not any *predefined* "=" for limited types.  You can define it
yourself.

If you have a component of a record that is an access to a limited type (as
in your earlier examples), and you don't want someone to be able to assign
or compare it (realizing of course that being able to assign/compare the
access object is not a back door to being able to have your way with the
denoted object), then maybe you can do something like this:

            type Foo_Handle is limited private;

            type Wumpus is record
                Something : Whatever;
                .
                .
                .
                Foo : Foo_Handle;
            end Record;

        private

            type Foo;

            type Foo_Handle is access Foo;


Note that:

1) type Wumpus is limited, because it has a limited component

2) This example does not depend on the full type of Foo being limited,
although it very well could be (e.g. it could be your protected type).

3) In this example the full type definition is deferred to the body, but the
example does not depend on this.  You could include the full type in the
private part (or even the public part) if you had a good reason, and
Foo_Handle and Wumpus would still be limited.

4) But don't go to this trouble because you think it closes a "back door" to
assigning to a limited type, because there is no such back door.

Hope this helps,
-- mark






      parent reply	other threads:[~2001-10-30 17:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-29 20:14 Re[2]: Limited Type Access - Again ANH_VO
2001-10-29 23:02 ` Matthew Heaney
2001-10-30  7:07 ` Sergey Koshcheyev
2001-10-30 17:10 ` Mark Lundquist [this message]
replies disabled

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