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.75.170 with SMTP id d10mr3992875pbw.6.1325849921372; Fri, 06 Jan 2012 03:38:41 -0800 (PST) Path: lh20ni142469pbb.0!nntp.google.com!news1.google.com!postnews.google.com!j10g2000vbe.googlegroups.com!not-for-mail From: Martin Newsgroups: comp.lang.ada Subject: Re: Ada2012 : Expression functions and extended return statements Date: Fri, 6 Jan 2012 03:37:27 -0800 (PST) Organization: http://groups.google.com Message-ID: <94808f24-938b-476e-8912-f98b52982d53@j10g2000vbe.googlegroups.com> References: <26f343ea-d694-4089-b594-f32b471db3a4@m4g2000vbc.googlegroups.com> NNTP-Posting-Host: 20.133.0.8 Mime-Version: 1.0 X-Trace: posting.google.com 1325849847 11628 127.0.0.1 (6 Jan 2012 11:37:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 6 Jan 2012 11:37:27 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j10g2000vbe.googlegroups.com; posting-host=20.133.0.8; posting-account=g4n69woAAACHKbpceNrvOhHWViIbdQ9G User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALERCFNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:10.0) Gecko/20100101 Firefox/10.0,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-01-06T03:37:27-08:00 List-Id: On Jan 6, 11:23=A0am, "Peter C. Chapin" wrote: > On 2012-01-06 05:02, Martin wrote: > > > I still think it would be nice to have a short-hand e.g. 'return > > Result :<> =A0do'. If anything it would then draw the eye to the more > > interesting case when the 2 are different. > > You need to repeat the type for ordinary returns as well. > > function F return Integer is > =A0 =A0Result : Integer; =A0-- Duplication of return type here. > begin > =A0 =A0Result :=3D 1; > =A0 =A0return Result; > end F; > > To be consistent it seems like you'd need to be able to use '<>' > throughout the body of the function. > > function F return Integer is > =A0 =A0Result : <>; =A0-- Shorthand for function's return type. > begin > =A0 =A0Result :=3D 1; > =A0 =A0return Result; > end F; > > Considering Ada's tendency to require one to repeat information in > earlier declarations, this seems a bit unAda-like to me. Also this would > allow '<>' to show up in a lot of strange looking places such as type > conversions and type qualifications. > > Peter The difference is that the declaration of 'Return' in the extended return is that the compiler 'knows' that this is the declaration of something that's going to be returned - it can't know that in the ordinary return case. Well, at least not when it first parses the declaration, not without just assuming it is...and that might be messy... It would certainly be a departure from current Ada - adding a little bit of "Type Inferencing" to the language. But I'm not adverse to that...so long as the inferencing is safe. I like SML/NJ :-) It's not that big a leap, at least not in my head, as "<>" is already used to mean "default" (i.e. infer what I mean from what's visible) and this would simply be "use the default return type, i.e. the one that's in the the function declaration". -- Martin