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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!postnews1.google.com!not-for-mail From: kevin.cline@gmail.com (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: 30 Sep 2004 17:04:31 -0700 Organization: http://groups.google.com Message-ID: References: <3673998.bj16mkkOu2@linux1.krischik.com> <1700922.2nPlMsa4Ny@linux1.krischik.com> <1636756.M7hCqjsVMv@linux1.krischik.com> <415c36c0$0$91010$39cecf19@news.twtelecom.net> NNTP-Posting-Host: 170.215.189.183 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1096589072 6988 127.0.0.1 (1 Oct 2004 00:04:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 1 Oct 2004 00:04:32 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:4473 Date: 2004-09-30T17:04:31-07:00 List-Id: "Matthew Heaney" wrote in message news:<415c36c0$0$91010$39cecf19@news.twtelecom.net>... > "Kevin Cline" wrote in message > news:e749549b.0409291942.5790386d@posting.google.com... > > > > There seems to be some confusion between creating a pointer to a > > particular member of a particular record, and the C++ pointer to > > member type. > > > > In C++: > [snip] > > There seems to be some confusion between creating an offset to a record > component, and simply using an Ada function pointer: > > In Ada: > > declare > type T is record > A, B : Integer; > end record; > > function A (O : T) return Integer is > begin > return O.A; > end; > > function B (O : T) return Integer is > begin > return O.B; > end; > > type Query_Type is access function (O : T) return Integer; > > Query : Query_Type := A'Access; > > O1 : T := (3, 5); > O2 : T := (4, 6); > > begin > > pragma Assert (Query (O1) = 3); > pragma Assert (Query (O2) = 4); > > Query := B'Access; > > pragma Assert (Query (O1) = 5); > pragma Assert (Query (O2) = 6); > > end; > > > > > The availability of pointers to members makes it possible to concisely > > express the mapping between the a data member and the "A" column of a > > database table. > > The availability of pointers to local functions makes it possible to > concisely express the mapping between the A record component and the "A" > column of a database table. I don't personally consider this to be particularly concise. There were two lines C++ code, one to declare the data member: int a; and one to create the table entry: db.insert("PERSON.SSN", &Person::ssn). There are at least six lines of Ada code: the member declaration, a function to access the data member, the instantiation of the insert function for members of that type, and finally the call of the instantiated function. Not much of a savings over simply writing separate create, read, and update functions for the record type.