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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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 w9mr6937241pbv.0.1325948224145; Sat, 07 Jan 2012 06:57:04 -0800 (PST) Path: lh20ni152818pbb.0!nntp.google.com!news2.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: Ada2012 : Expression functions and extended return statements Date: Sat, 7 Jan 2012 15:54:44 +0100 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <26f343ea-d694-4089-b594-f32b471db3a4@m4g2000vbc.googlegroups.com> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 X-Trace: tigger.scc.uni-weimar.de 1325948222 18606 141.54.178.228 (7 Jan 2012 14:57:02 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Sat, 7 Jan 2012 14:57:02 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Date: 2012-01-07T15:54:44+01:00 List-Id: On Fri, 6 Jan 2012, Martin wrote: > On Jan 6, 9:45�am, 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 -- like > > the ordinary return statement. See the following examples: > > > > � �function Characters(I: Integer; Filler: Character := '_') return String is > > � �begin > > � � � return Result: String(1..I) := (others => Filler) do > > � � � � return; > ^^^^^^^ > > I think you mean > null; > or > return Result: String(1..I) := (others => Filler); The following compiles fine (with gnat 2011), and the output is xxxyyx, as to be expected: with Ada.Text_IO; procedure Y is function Characters(I: Integer; Filler: Character := '_') return String is begin return Result: String(1..I) := (others => Filler) do return; end return; end Characters; begin Ada.Text_IO.Put(Characters(3, 'x')); Ada.Text_IO.Put(Characters(2, 'y')); Ada.Text_IO.Put(Characters(1, 'x')); Ada.Text_IO.Put(Characters(0, 'y')); end Y; > > > � � � end return; > > � �end Characters; > > > > � �type T is tagged record I: Integer; end record; > > � �type S is new T with record J: Natural; end record; > > > > � �function Fun(N, M: Natural) return T'Class is > > � �begin > > � � � return Result: S do > > � � � � Result.I := M; > > � � � � Result.J := N; > > � � � end return; > > � �end Fun; > > > > -- > > ---- Stefan.Lucks (at) uni-weimar.de, University of Weimar, Germany �---- > > � � > > ------ �I �love �the �taste �of �Cryptanalysis �in �the �morning! �------ > > > 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 > -- ---- Stefan.Lucks (at) uni-weimar.de, University of Weimar, Germany ---- ------ I love the taste of Cryptanalysis in the morning! ------