TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Subject:
From:
"Paul D. Stachour" <[log in to unmask]>
Date:
Sun, 16 Mar 1997 21:28:19 -0600
In-Reply-To:
<[log in to unmask]> from "David Shochat" at Mar 14, 97 11:02:03 am
X-To:
Reply-To:
"Paul D. Stachour" <[log in to unmask]>
Parts/Attachments:
text/plain (48 lines)
>
> Brett Kettering wrote:
> >
> > I have been doing a lot of work interfacing some C code to an Ada
> > routine.  I have a short version of an interesting problem.  I am using
> > GNAT V3.07 and gcc's C compiler on Solaris 2.5.
> >
> > In a C function I allocate memory and assign some strings to an argv
> > (char **) and pass that char ** and an argc (integer) to an Ada
> > procedure.  The Ada procedure receives the char ** into an
> > Interfaces.C.Strings.chars_ptr_array
>
> Stop right there. You're asking C to pass a parameter of an Ada
> unconstrained array type.
> You can't do that (except by doing very ugly Ada compiler-dependent
> things in the C like setting up the Ada descriptor/dope vector).
>
From one point of view, there are two type of languages:
  1) discriptered (like PL/I and Ada)
  2) discripterless (like FORTRAN and C)

In the first, it is the responsibility of the *compiler* to pass
along with every item transmitted from one subprogram to another,
a complete "descriptor" of information that the compiler knows, so that
the porgrammer can make use of it.  This might include array bounds,
element sizes, range restrictions, print-names, enumeration-values, and
other similar information.

In the second, it is responsibility of the *programmer* to keep track
of almost-everything (except the current-value) of an item passed
between procedures.

Whenever you call a descriptered language (e.g. Ada) from a descriptorless
one (e.g., C), the compiler has nothing to pass along.  And you get the
effects you noted.

The *simple fact* that the compiler passes this information, and that
the programmer does not have to keep track of it is but one source of
the increased reliability of languages like Ada over languages like C.
In one version of Glenford Myer's works on coupling and cohesion, the
requirement to pass two items to get the effect of one (i.e., passing both
the array base-address and its length separately like as in C instead
of as one-parameter as in Ada ) was called joing coupling.  My memory
is that this was *not* one of Glenford's names, but one proposed by
others working in this area.

..Paul

ATOM RSS1 RSS2