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.196.130 with SMTP id im2mr3811336pbc.3.1325844257153; Fri, 06 Jan 2012 02:04:17 -0800 (PST) Path: lh20ni141740pbb.0!nntp.google.com!news1.google.com!postnews.google.com!e2g2000vbb.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 02:02:57 -0800 (PST) Organization: http://groups.google.com Message-ID: 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 1325844185 18830 127.0.0.1 (6 Jan 2012 10:03:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 6 Jan 2012 10:03:05 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e2g2000vbb.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:9.0) Gecko/20100101 Firefox/9.0,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-01-06T02:02:57-08:00 List-Id: On Jan 6, 9:45=A0am, stefan-lu...@see-the.signature wrote: > On Fri, 6 Jan 2012, 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: > > I guess, this is because the object actually returned may not necessarily > be of exactly the same type of subtype as the declared return type -- lik= e > the ordinary return statement. See the following examples: > > =A0 =A0function Characters(I: Integer; Filler: Character :=3D '_') return= String is > =A0 =A0begin > =A0 =A0 =A0 return Result: String(1..I) :=3D (others =3D> Filler) do > =A0 =A0 =A0 =A0 return; ^^^^^^^ I think you mean null; or return Result: String(1..I) :=3D (others =3D> Filler); > =A0 =A0 =A0 end return; > =A0 =A0end Characters; > > =A0 =A0type T is tagged record I: Integer; end record; > =A0 =A0type S is new T with record J: Natural; end record; > > =A0 =A0function Fun(N, M: Natural) return T'Class is > =A0 =A0begin > =A0 =A0 =A0 return Result: S do > =A0 =A0 =A0 =A0 Result.I :=3D M; > =A0 =A0 =A0 =A0 Result.J :=3D N; > =A0 =A0 =A0 end return; > =A0 =A0end Fun; > > -- > ---- Stefan.Lucks (at) uni-weimar.de, University of Weimar, Germany =A0--= -- > =A0 =A0 > ------ =A0I =A0love =A0the =A0taste =A0of =A0Cryptanalysis =A0in =A0the = =A0morning! =A0------ Ah ok, yes, that makes sense...thanks. Never had need of this...yet! :-) I still think it would be nice to have a short-hand e.g. 'return Result : <> do'. If anything it would then draw the eye to the more interesting case when the 2 are different. -- Martin