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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx21.iad.POSTED!not-for-mail From: Brad Moore User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Question regarding example code in AI12-0140 References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 68.145.219.148 X-Complaints-To: internet.abuse@sjrb.ca X-Trace: 1414877489 68.145.219.148 (Sat, 01 Nov 2014 21:31:29 UTC) NNTP-Posting-Date: Sat, 01 Nov 2014 21:31:29 UTC Date: Sat, 01 Nov 2014 09:31:28 -0600 X-Received-Bytes: 3963 X-Received-Body-CRC: 3764161256 Xref: news.eternal-september.org comp.lang.ada:22964 Date: 2014-11-01T09:31:28-06:00 List-Id: On 14-10-31 01:40 PM, AdaMagica wrote: > Am Donnerstag, 30. Oktober 2014 16:59:31 UTC+1 schrieb Mark Lorenzen: >> In AI-0140 the following example code is given: >> >> with Ada.Unchecked_Deallocation; >> >> package UNC is >> >> type My_String (<>) is limited private; >> type My_String_Access is access My_String; >> private >> type My_String is new String; >> procedure Free is new >> Ada.Unchecked_Deallocation (My_String, My_String_Access); >> >> end UNC; >> >> The AI discusses if this is legal Ada or not. > > Hu - I've got severe problems to understand the AI. It says: > "The full view of My_String is constrained, while My_String_Access designates the partial view of My_String, which is unconstrained." > > But since when is type String constrained? So why is the full view of My_String constrained? > > Am I blind? > The AI needs some cleanup, and the sentence in the question that says; "The full view of My_String is constrained, while My_String_Access designates the partial view of My_String, which is unconstrained. " is misleading and incorrect, since as you you point out type My_String is an unconstrained subtype as defined in RM 3.2(9). The original issue was not really about the My_String type. It was about the My_String_Access type. It's declaration in the public part of the package is that of an access type that designates a type that has unknown discriminants. Any subtype of a type with unknown discriminants is an unconstrained and indefinite subtype. see RM 3.7 (26) However in the private part of the package where the instantiation occurs and the full view of My_String can be seen, we find out that My_String has no discriminants, which is not the same as having unknown discriminants. In the instantiation of Unchecked_Deallocation, the My_String generic formal has no discriminants. The other generic formal, Name has has to designate a type that statically matches the Object formal, yet at first glance these do not appear to match. RM 4.9.1 (1.2/2) A constraint statically matches another constraint if: both are static and have equal corresponding bounds or discriminant values; In the Appendix of the AI however, Tucker explains that for statically matching, it is the properties of the designated type that matter, not the properties of the access type that designates them. "The properties of the designated type change as you learn more about the designated type." He further points out that the access types in question are exactly the *same* type, so they should match each other statically. That is, both the access type declared in the public part of the package and the view of the access type in the private part designate the My_String type. So the effect of this AI would likely just be a clarification in the wording of the RM, but most compilers otherwise would not need any changes. In Randy's case he would need to make a change to his compiler, because he has a compiler bug. Brad