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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a644fa9cd1a3869a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-19 13:14:33 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: List container strawman 1.2 Date: 19 Nov 2001 16:08:22 -0500 Organization: NASA Goddard Space Flight Center Message-ID: References: <3BECA3B7.5020702@telepath.com> <3BF0247D.4500975E@san.rr.com> <5BXH7.22252$xS6.34813@www.newsranger.com> <3BF052D3.ECEF3FF2@san.rr.com> <3BF19FF8.7FE097EF@boeing.com> <3BF27410.C899A16B@brighton.ac.uk> <3BF3EDE5.FE0ED701@brighton.ac.uk> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1006204255 28191 128.183.220.71 (19 Nov 2001 21:10:55 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 19 Nov 2001 21:10:55 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: archiver1.google.com comp.lang.ada:16700 Date: 2001-11-19T21:10:55+00:00 List-Id: Ted Dennison writes: > In article <3BF3EDE5.FE0ED701@brighton.ac.uk>, John English says... > (good stuff all) > > > >Iterator is nice too but instantiating the generic (and wrapping the > >operation in an approapriately-shaped procedure first) is probably > >more hassle than a while I <> Last(L) loop, IMHO... > > That's my feelings on it too. Additionally, I've found you have to use globals > in the routine to get all of your real work done, which rubs the wrong way > against about 13 years of training on my part. But there are those here who > swear by passive iterators. I handle this in a different way in SAL. See the file sal-gen-alg-process_all_constant.ads for an example. The key point is that iterating thru a container is an _algorithm_. It is instantiated separately from the container (I know, that's too hard :). In fact, the algorithm can be instantiated in a local scope, so the "global variables" are local to that scope. Yet another design is to declare a "State_Type" generic formal for the iterator, like ASIS does for tree processing: generic type State_Type is limited private; with procedure Operation (Target : in out Element; State : in out State_Type; Quit : out Boolean); procedure Iterator (Target : in out List); This complicates things for users that don't need state, but they can just pass Integer. -- -- Stephe