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-Thread: 103376,b4a4dceda94869d2 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.35.131 with SMTP id h3mr98516pbj.1.1320811951370; Tue, 08 Nov 2011 20:12:31 -0800 (PST) Path: h5ni15110pba.0!nntp.google.com!news2.google.com!news4.google.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!192.87.166.28.MISMATCH!tudelft.nl!txtfeed1.tudelft.nl!feed.xsnews.nl!border-3.ams.xsnews.nl!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "R. Tyler Croy" Newsgroups: comp.lang.ada Subject: Re: Iterators in Ada2012 Date: Wed, 9 Nov 2011 04:12:29 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <66dbca36-0248-458a-aff4-1176d6ce098b@m10g2000vbc.googlegroups.com> <4eb92ae0$0$6581$9b4e6d93@newsspool3.arcor-online.net> Mime-Version: 1.0 Injection-Date: Wed, 9 Nov 2011 04:12:29 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="RGN/TepX2HLLmCAUtZUpgw"; logging-data="16500"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ACZrs2drDF36DHM68ui2a" User-Agent: Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master) Cancel-Lock: sha1:KoKkMXY3FnRQTo9caJGowxdIND0= Xref: news2.google.com comp.lang.ada:14362 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2011-11-09T04:12:29+00:00 List-Id: On Tue, 08 Nov 2011 14:13:03 +0100, Georg Bauhaus wrote: > On 08.11.11 11:05, comp.lang.php wrote: >> I have an instantiation of the package Ada.Containers.Ordered_Maps >> (Integer, Float). Is there a neat way of iterating over the values >> similar to the construction: >> for x of a_Set loop ... end loop. > > Fear of nesting a procedure? :-) > > I had thought that the new syntax of AI 139 would be for all containers. > > Strangely, the fashion seems to be moving elsewhere: > list comprehensions, Map + Reduce (US Patent #7,650,331), Scala, > ... all functional, hence little sympathy for for-loops. Sequence > comprehensions are now recommended when writing Python, so I had thought > there is all the more to say in favor of a simple automatic > > Container.Iterate (Process => Meaningful_Name'Access). The reasons things like list comprehensions and generator expressions are recommended in Python is because they're faster in the CPython implementation of the language since they get to native C "faster" (with less interpretation and bytecode). Additionally, generator expressiones: `(x for x in iterable)` are lazily evaluated so you don't have to actually have your working set in memory all at once. An Ada "built-in" equivalent of a generator expression I actually don't know of, I suppose you could hide that behind your Container.Iterate procedure? Cheers -- - R. Tyler Croy -------------------------------------- Code: http://github.com/rtyler