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,8a7b744efabb21c4 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!u12g2000prd.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Out parameters and unconstrained variant types Date: Thu, 26 Jun 2008 19:40:44 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: 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 1214534444 29838 127.0.0.1 (27 Jun 2008 02:40:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 27 Jun 2008 02:40:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u12g2000prd.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:901 Date: 2008-06-26T19:40:44-07:00 List-Id: On Jun 26, 5:22 pm, Gene wrote: > Hello friends, > > I would like to do something like: > > type Conditional_Result (Exists : Boolean := False) is > record case Exists is > when True => > Value : Natural; > when False => null; > end record; > > procedure Do_Something(x : in Natural; rtn : out Conditional_Result) > is > begin > if x = 0 then > rtn := (Exists => False); > else > rtn := (Exists => True; Value => x + 1); > end if; > end; > > procedure Foo is > rtn : Conditional_Result; > begin > Do_Something(0, rtn); > if rtn.Exists then > Put_Line("Yes!"); > end if; > Do_Something(1, rtn); > if rtn.Exists then > Put_Line("Yes!"); > end if; > end; > > ALRM 2005 and Barnes seem to say the procedure Do_Something will know > that rtn in foo is unconstrained and allow both calls to succeed. In > GNAT 2007, the second call fails with a constraint error at the > assignment to rtn. Can you tell me what I'm missing? It should work, and "anon" says he did get it to work with GNAT 2007. But your example isn't a complete program, so perhaps if you post the complete program you tried (assuming it's not much larger than this example), maybe we can see something additional that you did that would cause a problem. -- Adam