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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f494beedc5085953 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!2g2000hsn.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Obtaining access to protected object Date: Thu, 10 Jul 2008 07:46:53 -0700 (PDT) Organization: http://groups.google.com Message-ID: <58cc7c4b-f849-48cd-a65b-d4a345ddc048@2g2000hsn.googlegroups.com> References: <72741a06-d96c-4f53-a80b-3595c513efa1@27g2000hsf.googlegroups.com> <59ed2f49-92e7-4d9d-b88e-5fbd28824d91@p25g2000hsf.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1215701214 9655 127.0.0.1 (10 Jul 2008 14:46:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 10 Jul 2008 14:46:54 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 2g2000hsn.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1080 Date: 2008-07-10T07:46:53-07:00 List-Id: On Jul 9, 7:10 pm, george.p...@gmail.com wrote: > On Jul 9, 3:27 pm, Adam Beneschan wrote: > > > On Jul 9, 8:33 am, george.p...@gmail.com wrote: > > > > The instance may not be aliased, and type itself is not enough to > > > determine that at compile time. > > > Wrong. The current instance of a protected type is always considered > > aliased, and 'Access is allowed. 3.10(9/2). > > > -- Adam > > I may be wrong, You're definitely wrong about the rules. If there's a possibility that the rules can allow a programmer to write a legal program that creates a dangling reference (without involving certain dangerous features), then the ARG needs to hear about it. But I don't think that's the case here. The biggest problem, as far as I know, with allowing something to access an unaliased object, is that the compiler may not realize that something could point to it, and therefore could optimize certain calculations so that the object doesn't necessarily hold the right value when expected, which will then be a problem if the program does a dereference of the access. However, none of this reasoning applies to protected types, or task types. In fact, there would probably be no accessing problem at all if *all* protected and task objects were considered aliased, even without an explicit "aliased" keyword. See AARM 3.10(9.l/2) [that's "nine" "dot" "the lower-case letter L"]; the ARG actually considered doing this for all by-reference types (which would include task and protected types, as well as all tagged types and all limited record types). They decided not to do so because of some problems involving private parts. > but it seems that Aliaseness is guaranteed only within > the protected body. So taking pointer and spilling it outside of the > scope (even if allowed) is bad idea IMHO. See above; there's no danger in letting such pointers outside, even if the object is not explicitly declared as "aliased". Were it not for some problems involving privacy breakage, the ARG saw no danger in simply decreeing that all protected types, etc., are automatically aliased. > If used inside the > protected body then what's advantage of using pointer vs. referring > directly? Because you could have an object of an access-to-protected type that could, in some instances, be set to the same protected type, or could be set to point to some other protected type. Of course there's little point in setting up a pointer that always refers to the same object; the idea is that you could modify it to point to something else. -- Adam