* Re[2]: Limited Type Access - Again
@ 2001-10-29 20:14 ANH_VO
2001-10-29 23:02 ` Matthew Heaney
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ANH_VO @ 2001-10-29 20:14 UTC (permalink / raw)
To: comp.lang.ada
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. I think this door should be locked. In addition, comparing or
assignment two objects of a task type does not make sense. 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.
Anh Vo
____________________Reply Separator____________________
Subject: Re: Limited Type Access - Again
Author: "Matthew Heaney" <mheaney@on2.com>
Date: 10/29/01 4:25 PM
<ANH_VO@udlp.com> wrote in message
news:mailman.1004389122.4372.comp.lang.ada@ada.eu.org...
> It looks to me that equality and assignment do not make sense at all.
I don't understand your objection. The default equality operator for record
types is defined as the conjunction of equality of all the record
components. What behavior were you expecting?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re[2]: Limited Type Access - Again 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 2 siblings, 0 replies; 4+ messages in thread From: Matthew Heaney @ 2001-10-29 23:02 UTC (permalink / raw) <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. A record type is limited if it has limited components: task type T; type RT is record O : T; end record; O1, O2 : RT; O1 := O2; --will NOT compile if O1 = O2 then --will NOT compile > I think this door should be locked. Already done. This was true already in Ada83. > In addition, comparing or > assignment two objects of a task type does not make sense. It's up to you to decide whether task comparison makes sense. Note that in Ada95 you can compare Task_Id's. > 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. Not quite -- you don't ever have assignment, but you don't have equality *by default*. Meaning you can provide your own equality operator for a limited type: type RT is limited record ... end record; function "=" (L, R : RT) return Boolean is ... Or even: task type TT; function "=" (L, R: TT) return Boolean is... ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re[2]: Limited Type Access - Again 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 2 siblings, 0 replies; 4+ messages in thread From: Sergey Koshcheyev @ 2001-10-30 7:07 UTC (permalink / raw) <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. I think this door should be locked. In addition, comparing or > assignment two objects of a task type does not make sense. 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. But you don't compare and assign *objects* in your example, you compare and assign *pointers* to those objects. Why should the latter not be allowed? Sergey Koshcheyev. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re[2]: Limited Type Access - Again 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 2 siblings, 0 replies; 4+ messages in thread From: Mark Lundquist @ 2001-10-30 17:10 UTC (permalink / raw) <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 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-10-30 17:10 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox