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,cced0e2ac94722f3 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.74.201 with SMTP id w9mr5364343pbv.0.1325888021693; Fri, 06 Jan 2012 14:13:41 -0800 (PST) Path: lh20ni147279pbb.0!nntp.google.com!news1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Ada2012 : Expression functions and extended return statements Date: Fri, 06 Jan 2012 17:12:29 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <26f343ea-d694-4089-b594-f32b471db3a4@m4g2000vbc.googlegroups.com> <9d181c23-2d64-4947-a6f7-64e0dcda357b@f11g2000yql.googlegroups.com> <02c279d0-7603-4670-af1a-cbf5894231ea@f1g2000yqi.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls6.std.com 1325887949 32329 192.74.137.71 (6 Jan 2012 22:12:29 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 6 Jan 2012 22:12:29 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:VJuTPZBpIRHua5zUZx/hWqwhc60= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: 2012-01-06T17:12:29-05:00 List-Id: Adam Beneschan writes: > On Jan 6, 8:33�am, Adam Beneschan wrote: >> On Jan 6, 12:45�am, Martin wrote: >> >> > Also, on the topic of extended return statements... >> >> > What's the rational for having to explicitly repeat the return type? >> > Seems rather redundant to my eyes. I wouldn't have minded: >> >> > function Bar return Some_Type is >> > begin >> > � �return Result : <> do >> > � � � -- something to initialise 'Result' >> > � �end return; >> > end Bar; >> >> > or even >> >> > function Bar return Some_Type is >> > begin >> > � �return Result do >> > � � � -- something to initialise 'Result' >> > � �end return; >> > end Bar; >> >> > In this case, 'Result' can't be anything other than of type >> > 'Some_Type' can it? >> >> Yes, it can. �If Some_Type is a class-wide type, Result's type must be >> a specific type. �If Some_Type is, say, an unconstrained array type, >> Result's type must be a constrained subtype. > > Oops, I goofed. Result's type doesn't *have* to be a specific, > constrained subtype, if there is an initial value (which could be a > function call, say); the specific type and subtype are then determined > from the value. If there is no initial value, however, then Result's > type does have to be constrained. Well, the examples above don't have an initial value, so I took your "must be constrained" comment to mean "for this example, because there's no initial value". Anyway, the rule is the same as for an object_declaration -- if there's no initial value, the subtype has to be definite. - Bob