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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.190.66 with SMTP id o63mr5085540iof.65.1520883296042; Mon, 12 Mar 2018 12:34:56 -0700 (PDT) X-Received: by 10.157.4.22 with SMTP id 22mr525474otc.2.1520883295761; Mon, 12 Mar 2018 12:34:55 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!r195no1369460itc.0!news-out.google.com!a25ni3922itj.0!nntp.google.com!e10-v6no1364233itf.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 12 Mar 2018 12:34:55 -0700 (PDT) In-Reply-To: <2153155f-2778-421f-97cb-4d229fb9355b@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.218.37.33; posting-account=W2gdXQoAAADxIuhBWhPFjUps3wUp4RhQ NNTP-Posting-Host: 76.218.37.33 References: <4cf2a76e-626d-4ead-ae8a-dccdef41b283@googlegroups.com> <2153155f-2778-421f-97cb-4d229fb9355b@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <290ddbd1-3aa1-4238-8737-51d8090af7d3@googlegroups.com> Subject: Re: anonymous records as tuples From: Stephen Leake Injection-Date: Mon, 12 Mar 2018 19:34:56 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 2590 X-Received-Body-CRC: 1208570422 Xref: reader02.eternal-september.org comp.lang.ada:50942 Date: 2018-03-12T12:34:55-07:00 List-Id: On Monday, March 12, 2018 at 2:17:08 PM UTC-5, Robert Eachus wrote: > On Monday, March 12, 2018 at 1:32:46 PM UTC-4, Stephen Leake wrote: > > I recently had to change a function that returned a single integer into a procedure that returns two... > > What is wrong with something like: > > -- in Tree: > > type Return_Values is record > Real : Integer; > Virtual : Integer; > end record; > > function Count_Terminals (Index...) return Return_Values; > ... > > declare > Returned: constant Tree.Return_Values := Tree.Count_Terminals(Index); > Real: Integer renames Returned.Real; > Virtual: Integer renames Returned.Virtual; > begin > if Virtual = 0 then > Next_Shared_Token := Next_Shared_Token - Real; > end if; > end; That works, but is more verbose; I have to make up a name for the result type, when it's really an anonymous tuple of values. But I suspect the ARG would say the gain is not worth the cost. > (And declaring Real as an Integer really rubs me wrong.) This is for a parser; it's counting "real tokens" from the source text versus "virtual tokens" inserted by an error recovery process. I ended up resolving it a different way; first I check if there are any virtual tokens, then I count real tokens. -- Stephe