Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)

From: Kevin Cline (kevin.cline_at_gmail.com)
Date: 10/01/04


Date: 30 Sep 2004 17:04:31 -0700


"Matthew Heaney" <mheaney@on2.com> wrote in message news:<415c36c0$0$91010$39cecf19@news.twtelecom.net>...
> "Kevin Cline" <kevin.cline@gmail.com> 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.



Relevant Pages

  • Re: Why MFC doesnt like /vmg?
    ... > before you declare a pointer to a member of the class. ... > pointer to a member of a class before defining the class. ... >>>out it will make the MFC application work improperly. ...
    (microsoft.public.vc.mfc)
  • Re: Why MFC doesnt like /vmg?
    ... These options select the method that the compiler uses to represent pointers ... before you declare a pointer to a member of the class. ... pointer to a member of a class before defining the class. ...
    (microsoft.public.vc.mfc)
  • Re: Casting of pointer to member functions
    ... cast it back before any usage. ... The example above will compile only if /ymg compiler switch ... the bits that pointer is ... calling a member function through such pointer is ...
    (microsoft.public.vc.language)
  • Re: Problem bei for Anweisung
    ... wenn man ein char-Feld hat. ... — if it has pointer type, it is initialized to a null pointer; ... if it is an aggregate, every member is initialized ... according to these rules; ...
    (de.comp.lang.c)
  • Re: Class members, pointers or not?
    ... > Is it best to declare class member objects as pointers or not pointers? ... using pointer members (and reference members) ...
    (comp.lang.cpp)