comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: Why does Ada.Iterator_Interfaces specify Next as a function rather than a procedure?
Date: Wed, 6 Sep 2017 18:29:06 -0700 (PDT)
Date: 2017-09-06T18:29:06-07:00	[thread overview]
Message-ID: <ba860d9f-7e5f-431b-826b-76a6347db38e@googlegroups.com> (raw)
In-Reply-To: <9677f15f-c612-4ac4-9c2d-64fbf530873e@googlegroups.com>

On Wednesday, September 6, 2017 at 8:04:15 PM UTC-5, Stephen Leake wrote:
> >      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;

I don't see how to do this; 'Reversible_Iterator' is defined in an instantiation of Ada.Iterator_Interfaces, which takes the type My_Iterator as a generic parameter.

Just leaving that off still fails, if I try to make the contents of the cursor private while exposing the Iterate function.

Are you relying on some new Ada 202x syntax here?
> > 
> >      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

  reply	other threads:[~2017-09-07  1:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-06  7:49 Why does Ada.Iterator_Interfaces specify Next as a function rather than a procedure? Stephen Leake
2017-09-06 21:50 ` Randy Brukardt
2017-09-07  1:04   ` Stephen Leake
2017-09-07  1:29     ` Stephen Leake [this message]
2017-09-07 23:14       ` Randy Brukardt
2017-09-07  2:53 ` Charles H. Sampson
2017-09-07  6:16 ` briot.emmanuel
2017-09-07 23:17   ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox