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,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) References: <41547dae$0$91007$39cecf19@news.twtelecom.net> <1g2d9xmnita9f.5ecju0eftkqw$.dlg@40tude.net> <1hl2mizeb27ku$.1f0asrbmb05mi.dlg@40tude.net> <7siml3c62lev$.usczt2y2l19c$.dlg@40tude.net> <15fk5715wm38q.3ie9r3bq8yuz$.dlg@40tude.net> <1ob4dexep087b$.ul8fb1ebgeok.dlg@40tude.net> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 04 Oct 2004 12:16:58 GMT NNTP-Posting-Host: 64.185.133.124 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1096892218 64.185.133.124 (Mon, 04 Oct 2004 05:16:58 PDT) NNTP-Posting-Date: Mon, 04 Oct 2004 05:16:58 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:4655 Date: 2004-10-04T12:16:58+00:00 List-Id: "Dmitry A. Kazakov" writes: > It is because they are not arrays. But why an ordered list should not > implement an array interface? In my view it should, making the above > legal for lists. Stop obsessing about syntax. If you want a consistent interface for containers, you have that in AI-302 (but of course it's not an "array" interface): procedure Op (Container : ) is C : Cursor := First (Container); begin while Has_Element (C) loop Process (C); --or Process (Element (C)) Next (C); end loop; end Op; Actually, if you intend on iterating over all the elements in a container, the passive iterator is preferred: procedure Op (Container : is begin Container.Iterate (Process'Access); end; If you have an array type, then you can give it a container-like interface for the purpose of binding an array object to a generic algorithm. I showed how to do this in an earlier post. > I do! I hate implicit iterators, I prefer loops where > possible. Especially, because exit conditions, nested iterations, > exception handling become visible. If you intend on traversing every element in the container, then use a passive iterator. It's more efficient, and less error-prone. If you have exit conditions, then go ahead and use an active-iterator style loop. > [ Ranting: 40 years spent in developing readable, safe, well-structured > language constructs, only to replace them with nested function calls a la > Lisp? ] This is a specious comparison.