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,fc52c633190162e0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!p15g2000hsd.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Use of declare blocks Date: 21 Mar 2007 18:17:44 -0700 Organization: http://groups.google.com Message-ID: <1174526264.909551.159140@p15g2000hsd.googlegroups.com> References: <1172144043.746296.44680@m58g2000cwm.googlegroups.com> <1172161751.573558.24140@h3g2000cwc.googlegroups.com> <546qkhF1tr7dtU1@mid.individual.net> <5ZULh.48$YL5.40@newssvr29.news.prodigy.net> <4eeMh.16400$bb1.2557@newssvr17.news.prodigy.net> <460198f2$0$24601$39db0f71@news.song.fi> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1174526266 21068 127.0.0.1 (22 Mar 2007 01:17:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 22 Mar 2007 01:17:46 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: p15g2000hsd.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news1.google.com comp.lang.ada:14587 Date: 2007-03-21T18:17:44-07:00 List-Id: On Mar 21, 2:29 pm, "Randy Brukardt" wrote: > "Niklas Holsti" wrote in message > > > declare > > > Junk : Index; > > > begin > > > Insert_Something (..., Result => Junk); > > > end; > > > > where the result isn't needed by the following code. > > > How about a language extension to omit unused out parameters, for example > > > Insert_Something (..., Result => <>); > > > Perhaps even allowing declaration of optional out parameters, as in > > > procedure Insert_Something (..., Result : out Index := <>); > > > and then a call of Insert_Something could omit Result entirely. > > I think both of these would be a tough sell. Not to me. Well, maybe the second one would be. But the first one, the ability to call a procedure with a "please discard this" syntax for an OUT parameter, is something I've often considered suggesting too. Of course, it's just syntactic sugar so it's not all that important, which is one reason why I never bothered to send a proposal to Ada-Comment. But I think it would be a cool feature. I'd use it. > After all, once of the good things about Ada is that you have to do > something explicit to ignore returned values (including error returns). If > they're mapped as out parameters, you have to write code to discard them > (like the above). If they're mapped as exceptions, you have to handle and > ignore (with a null handler) the exception (or all exceptions). Both of > these are obvious when reading the code. It's a lot harder to detect an > error of omission than an error of commission. I'm guessing that you meant this argument to apply only to Niklas's second suggestion, which would allow the out parameter to be eliminated entirely from the procedure call; having something like "Result => <>" in a procedure call seems to satisfy your requirement that you'd have to write code to discard the parameter. -- Adam