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: <11b4d.3849$d5.30042@newsb.telia.net> <1096033431.100639@master.nyc.kbcfp.com> <41546201$0$91006$39cecf19@news.twtelecom.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: Wed, 29 Sep 2004 22:44:52 GMT NNTP-Posting-Host: 64.185.133.124 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1096497892 64.185.133.124 (Wed, 29 Sep 2004 15:44:52 PDT) NNTP-Posting-Date: Wed, 29 Sep 2004 15:44:52 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:4413 Date: 2004-09-29T22:44:52+00:00 List-Id: Mark Lorenzen writes: > After having thought about this a bit, I would say that an equivalent > of C++s function classes is missing. > > If function classes were introduced, we could build pretty powerful > algorithms traversing the different containers and f.ex. implement an > infinite list (also called lazy list) container. Right now the > containers only allow for a procedure to process the elements of a > container. Well, you can do that using the procedure, and depositing a result somewhere prior to returning. For example, in the wordcount example, you need to compute a predicate function on map cursors: Sort_Vector : declare function "<" (L, R : Wordcount_Maps.Cursor) return Boolean is Result : Boolean; procedure Query_L (LK : String; LN : Natural) is procedure Query_R (RK : String; RN : Natural) is begin if LN > RN then Result := True; elsif LN < RN then Result := False; else Result := Ada.Strings.Less_Case_Insensitive (LK, RK); end if; end Query_R; begin Query_Element (R, Query_R'Access); end; begin Query_Element (L, Query_L'Access); return Result; end; procedure Sort is new Wordcount_Vectors.Generic_Sort; begin Sort (V); end Sort_Vector; This does everything the a "function class" would do in C++. The ARG is currently discussing whether to allow functions to return anonymous access types, which would allow us to write the predicate as: function "<" (L, R : Wordcount_Maps.Cursor) return Boolean is Result : Boolean; LN : Natural renames Query_Element (L).all; LN : Natural renames Query_Element (R).all; begin if LN > RN then return True; end if; if LN < RN then return False; end if; declare LK : String renames Query_Key (L).all; RK : String renames Query_Key (R).all; begin return Ada.Strings.Less_Case_Insensitive (LK, RK); end; end "<"; Please give me a specific, concrete example of something you can do in C++, that you believe cannot be done using the AI-302 container library.