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,f4c347649cc4d329 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Another question about controlled types. References: <47ae13b2$0$32493$4d3efbfe@news.sover.net> In-Reply-To: <47ae13b2$0$32493$4d3efbfe@news.sover.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1202593802 12.201.97.213 (Sat, 09 Feb 2008 21:50:02 GMT) NNTP-Posting-Date: Sat, 09 Feb 2008 21:50:02 GMT Organization: AT&T ASP.att.net Date: Sat, 09 Feb 2008 21:50:02 GMT Xref: g2news1.google.com comp.lang.ada:19752 Date: 2008-02-09T21:50:02+00:00 List-Id: Peter C. Chapin wrote: > I'm using GNAT GPL 2007. I understand that Ada 2005 allows one to return > limited types from functions. Consider the following package > specification and body: > > package Check is > type Some_Type is limited private; > function Make(I : Integer) return Some_Type; > private > type Some_Type is > record > Component : Integer; > end record; > end Check; The full view is not limited. > with Ada.Finalization; > > package Check is > type Some_Type is limited private; > function Make(I : Integer) return Some_Type; > private > type Some_Type is new Ada.Finalization.Limited_Controlled with > record > Component : Integer; > end record; > end Check; Here the full view is limited. That is the difference. To return a limited value, you now need to either return an aggregate or use the extended return statement: return Some_Type'(Ada.Finalization.Limited_Controlled with Component => I); or return Result : Some_Type do Result.Component := I; end return; See ARM 6.5. -- Jeff Carter "I soiled my armor, I was so scared." Monty Python & the Holy Grail 71