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.13.211.196 with SMTP id v187mr701353ywd.109.1504746253848; Wed, 06 Sep 2017 18:04:13 -0700 (PDT) X-Received: by 10.36.51.202 with SMTP id k193mr110451itk.14.1504746253790; Wed, 06 Sep 2017 18:04:13 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!q8no399568qtb.0!news-out.google.com!p6ni1108itp.0!nntp.google.com!o200no47154itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 6 Sep 2017 18:04:13 -0700 (PDT) In-Reply-To: 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: <693d41af-1da7-4c47-825a-198a082aaf9a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9677f15f-c612-4ac4-9c2d-64fbf530873e@googlegroups.com> Subject: Re: Why does Ada.Iterator_Interfaces specify Next as a function rather than a procedure? From: Stephen Leake Injection-Date: Thu, 07 Sep 2017 01:04:13 +0000 Content-Type: text/plain; charset="UTF-8" Xref: news.eternal-september.org comp.lang.ada:47959 Date: 2017-09-06T18:04:13-07:00 List-Id: On Wednesday, September 6, 2017 at 4:50:49 PM UTC-5, Randy Brukardt wrote: > (1) The ARG is looking at alternative kinds of iterators for Ada 2020. See > AI12-0188-1 and AI12-0189-1 (probably only one of these will be used). Interesting, but neither addresses my issue; the definition of Next as a function does not change. 189 mentions my problem ("often using the Rosen trick"), but seems to think the Rosen trick is an acceptable solution. A unified cursor does make sense for my application. > type State is record > -- The components of the state. > end record; > > type My_Iterator is new Ada.Finalization.Controlled and > Reversible_Iterator with record > My_State : access State; -- Writable state. > The_State : aliased State; > end record; > > procedure Initialize (Obj : in out My_Iterator) is > begin > Obj.My_State := The_State'Access; -- (*) > end Initialize; > This is a legitimate technique -- it is NOT erroneous in Ada > 2012 -- so if your compiler has problems with it, file a bug report and if > they don't believe that, send me a proposed ACATS test! You are implying that my worry about the compiler assuming the input and output of Next must point to different items is not valid. I'll give it a try. -- Stephe