From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.8 required=3.0 tests=BAYES_50,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a05:6214:1c46:: with SMTP id if6mr32852399qvb.41.1624994726319; Tue, 29 Jun 2021 12:25:26 -0700 (PDT) X-Received: by 2002:a25:6d02:: with SMTP id i2mr39758000ybc.309.1624994726121; Tue, 29 Jun 2021 12:25:26 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 29 Jun 2021 12:25:25 -0700 (PDT) Injection-Info: google-groups.googlegroups.com; posting-host=209.104.249.61; posting-account=1tLBmgoAAAAfy5sC3GUezzrpVNronPA- NNTP-Posting-Host: 209.104.249.61 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <69a59fdc-72bb-4202-99fc-d776530de653n@googlegroups.com> Subject: calling function but ignoring results From: Matt Borchers Injection-Date: Tue, 29 Jun 2021 19:25:26 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:62298 List-Id: It is not very often that ignoring a function result is okay, but I have ru= n across many instances of the following block structure in code over the y= ears: declare dont_care : BOOLEAN; begin dont_care :=3D foo( x, y ); end; I also see the procedure wrapper used in some cases -- usually when exporte= d in a package specification: procedure FOO( x, y ) is b : BOOLEAN; begin b :=3D foo( x, y ); end FOO; The procedure adds nothing to the code except another thing to maintain whe= n the function interface needs modification. Is there a Ada 202x feature to support calling functions and ignoring the r= esult? If not, I'm wondering if the @ symbol recently introduced for assig= nments could be used? How would people feel about the following? @ :=3D foo( x, y ); This would discard the result of the function. This could obviously lead t= o memory leaks (without reference counting), but the syntax could be restri= cted for use on functions that do not return uncontrolled access types or t= hese functions could be marked with a keyword to make it legal for it to be= called in such a way when the programmer knows that the access returned sh= ould not be "freed" by the caller (such as a pointer into an existing struc= ture). I have not given this much thought so I'm sure there are reasons why this c= an't (or shouldn't) be done in general. Regardless, there are probably man= y that would agree with me that the declare block and the wrapper procedure= options are annoying and could be considered superfluous for lack of a bet= ter way to write the code more simply. Matt