From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ab66185f2bca0483 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-14 03:44:02 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fr.usenet-edu.net!usenet-edu.net!enst.fr!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: Extension of non-limited type needs limited component Date: Thu, 14 Nov 2002 05:43:47 -0600 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <2dbd76f3.0211130203.7d2d14fd@posting.google.com> <2dbd76f3.0211140126.5d233e41@posting.google.com> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1037274242 10847 137.194.161.2 (14 Nov 2002 11:44:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 14 Nov 2002 11:44:02 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:30863 Date: 2002-11-14T05:43:47-06:00 ----- Original Message ----- From: "Mike" Newsgroups: comp.lang.ada To: Sent: November 14, 2002 3:26 AM Subject: Re: Extension of non-limited type needs limited component > I wrote > > > > How do I extend a non-limited tagged type to add a limited component? > > Jean-Pierre Rosen replied > > > You can't. Make the original type limited. > > The whole hierarchy has to be limited (or not limited, excluding adding a > > limited element). The reason is that otherwise, you could end up trying to > > assign a variable with a limited component. > > Unfortunately I can't make the base type limited as it is a generic > gui dialog base 'class'. > > I understand that I would need to make the extended type limited to > avoid the possible assignment to the limited component, but I cannot > see why I should have to make the whole hierarchy limited. > > How can assignment by upcasting the extended type possibly affect the > limited component? > Since the purpose of "limited" is to prevent having multiple copies of the same object (e.g. an object of Ada.Text_IO.File_Type) wherein changing the state of one of the copies is changed (e.g. by closing the file in the previous example) would leave the other copy in an incorrect state, allowing limited components in a non-limited record would violate this principle. On the other hand, if multiple access objects are used to designate the same limited object, then changes to the state by reference through one of the access objects will be reflected in all of the access objects designating that limited object. Of course, the specifier of a limited type may provide a Copy procedure (e.g., with a declaration like procedure Copy (From : My_Limited_Type; To : out My_Limited_Type); In that case, the fact that use of a Copy procedure is required, rather than a simple assignment, makes the user of the type aware, that he is creating a new distinct object, not a new reference to an existing object.