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!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread3.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: <338040f8.0409230912.70e3375b@posting.google.com> 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: Sun, 26 Sep 2004 14:57:33 GMT NNTP-Posting-Host: 64.185.133.124 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.atl.earthlink.net 1096210653 64.185.133.124 (Sun, 26 Sep 2004 07:57:33 PDT) NNTP-Posting-Date: Sun, 26 Sep 2004 07:57:33 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:4212 Date: 2004-09-26T14:57:33+00:00 List-Id: kevin.cline@gmail.com (Kevin Cline) writes: > > Back to Ada, i'm agree with you, your Ada code is not very readable : > > I'm not the author. The Ada code was written by Matthew Heaney, the > author of Charles. The ARG is bandying about the idea of allowing functions to return an anonymous access type, something like: function Element (C : Cursor) return not null access Element_Type; This would allow that part of the program that increments the word count to be written like this: declare C : Cursor; B : Boolean; begin Insert (M, Word, 0, C, B); declare N : Natural renames Element (C).all; begin N := N + 1; end; end; Still not as concise as the C++ index and increment operators, but it's less verbose the original example. If we were to write the C++ example using insert(), it would look something like: typedef map_t::iterator iter_t; typedef pair status_t; const status_t status = m.insert(make_pair(word, 0)); const iter_t& iter = status.first; int& n = iter->second; ++n; So now they don't look that much different. In fact, the 5-parameter Insert operation in the AI-302 API is modeled directly on the C++ code fragment above. -Matt