comp.lang.ada
 help / color / mirror / Atom feed
From: "R. Tyler Croy" <tyler@linux.com>
Subject: Re: Iterators in Ada2012
Date: Wed, 9 Nov 2011 04:12:29 +0000 (UTC)
Date: 2011-11-09T04:12:29+00:00	[thread overview]
Message-ID: <j9cujd$g3k$1@dont-email.me> (raw)
In-Reply-To: 4eb92ae0$0$6581$9b4e6d93@newsspool3.arcor-online.net

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



  parent reply	other threads:[~2011-11-09  4:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 10:05 Iterators in Ada2012 comp.lang.php
2011-11-08 13:13 ` Georg Bauhaus
2011-11-08 13:42   ` Dmitry A. Kazakov
2011-11-09  4:12   ` R. Tyler Croy [this message]
2011-11-09  9:02     ` Simon Wright
2011-11-09 22:58       ` R. Tyler Croy
2011-11-10  8:07         ` Georg Bauhaus
2011-11-09 10:55     ` Georg Bauhaus
2011-11-25 14:20       ` Yannick Duchêne (Hibou57)
2011-11-08 21:25 ` 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