comp.lang.ada
 help / color / mirror / Atom feed
From: Lionel.DRAGHI@fr.thalesgroup.com
To: comp.lang.ada@ada-france.org
Subject: iterators as  first class objects
Date: Mon, 22 Dec 2003 17:19:22 +0100
Date: 2003-12-22T17:19:22+01:00	[thread overview]
Message-ID: <mailman.155.1072110014.31149.comp.lang.ada@ada-france.org> (raw)



| -----Message d'origine-----
| De: Robert I. Eachus 
...
| But the trick of having data structure packages return an 
| array view of 
| a collection, or actually an array of access values, is very, very 
| useful.

I also really like this idiom, but there are drawbacks:

1 - you get more job done:
First within the data structure component, you have to build the array. 
If the internal structure is not already an array, you will probably need an
actual iterator.
Then, within the user's code, there is the "for i in " loop.
With an iterator, there is only one loop.

2 - within the component, the whole array is build: with an iterator, you
may exit before the end.

This is why we use it only for small data structure. 

As this leads to crystal-clear user's code, and as it's a common need, I
think it's worth thinking about langage extension.
   
-- 
Lionel Draghi



             reply	other threads:[~2003-12-22 16:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-22 16:19 Lionel.DRAGHI [this message]
2003-12-22 21:37 ` iterators as first class objects Robert I. Eachus
replies disabled

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