Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)
From: Kevin Cline (kevin.cline_at_gmail.com)
Date: 10/01/04
- Next message: Jeffrey Carter: "Re: access private element of base-class"
- Previous message: Kevin Cline: "Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)"
- Maybe in reply to: Robert Kawulak: "Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)"
- Next in thread: Georg Bauhaus: "Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)"
- Reply: Georg Bauhaus: "Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Next message: Jeffrey Carter: "Re: access private element of base-class"
- Previous message: Kevin Cline: "Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)"
- Maybe in reply to: Robert Kawulak: "Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)"
- Next in thread: Georg Bauhaus: "Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)"
- Reply: Georg Bauhaus: "Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|