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,fc52c633190162e0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.germany.com!feeder.ecngs.de!ecngs!feeder2.ecngs.de!npeer.de.kpn-eurorings.net!npeer0.kpn.DE!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Use of declare blocks Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH 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> Date: Thu, 22 Mar 2007 09:34:20 +0100 Message-ID: <11vkijhsuuugr$.1qcomlp8kkeke$.dlg@40tude.net> NNTP-Posting-Date: 22 Mar 2007 09:34:20 CET NNTP-Posting-Host: 16b66fb6.newsspool3.arcor-online.net X-Trace: DXC=:[[2^BQ6iD2lIh70@\BH3Y2KYQ2DP^03k:DNcfSJ;bb[5FCTGGVUmh?4LK[5LiR>kg2JQLekXCO>67 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:14592 Date: 2007-03-22T09:34:20+01:00 List-Id: On Wed, 21 Mar 2007 22:43:58 +0200, Niklas Holsti wrote: > Randy Brukardt wrote: > >> I use declare blocks extensively to reduce the scope of temporary variables >> in subprograms. They're especially important when the object exists just to >> take an unused out parameter, because they greatly reduce the need to come >> up with names for the objects. I often have code like: >> >> 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 => <>); Unused function results are even more offending. I would like to see: null ; instead of declare Dummy : Guess_What; begin Dummy := ; end; > 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. That could be difficult because of discriminants. Consider: procedure Insert_Something (..., Result : in out String (1..80) := <>); procedure Insert_Something (..., Result : in out String (<>) := <>); ... I guess if optional [in] out parameters weren't better solvable with lazy expressions. If the latter were supported one could provide a non-intrusive default for outs without magical stuff like <>. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de