comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin D. Condic" <mcondic-nospam@quadruscorp.com>
Subject: Re: Nontrivial examples of C interface with Ada
Date: 2000/05/24
Date: 2000-05-25T03:28:29+00:00	[thread overview]
Message-ID: <392CC733.13BDDC84@quadruscorp.com> (raw)
In-Reply-To: 8ghbqc$ram$1@nnrp1.deja.com

Ted Dennison wrote:
> "Semi-thick" is my term for my own favorite style for bindings. A
> "semi-thick" binding is one that abstracts away typical stupid C
> artifacts like pointer interfaces, return error codes, and
> null-termiated strings. That way the interface "feels" like Ada. But it
> doesn't abstract things so much that the C docs for the routine can't be
> used for the Ada bindings.
> 
That's about the depth I'd like to see bindings done. Get rid of
pointers to everything, use normal Ada strings, enumeration types for
return codes, etc. Of course you quite often run into cases where the
normal C way to do things is with a function and you have to make it
into a procedure in order to have it make proper sense in Ada, so you
always have little compromises to make. However, you at least want to
attempt to make it close to the original routine, only doing your best
to make it more Ada-ish.

One problem area I have found is with the use in C of error codes &
flags. The usual C method is to declare a long list of constants -
sometimes where the specific bits in the constants have particular
meanings (intended to be or'ed together). You would prefer enumerated
types, but there is often no clear grouping of the return codes.
Sometimes a constant is used for one type of thing and sometimes for
another (as in sometimes its a return status and sometimes its a
parameter). When the codes are used in the manner of flags (or'ed
together) you don't always have a good mapping onto an Ada method which
doesn't simply degenerate to an ugly C-ism. Maybe it would be useful to
develop a set of guidelines as to how to do these sorts of translations?
I certainly end up stumped sometimes as to what is the best choice and
some consistent guidelines would be handy.

MDC
-- 
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

"I'd trade it all for just a little more"
    --  Charles Montgomery Burns, [4F10]
======================================================================




  reply	other threads:[~2000-05-24  0:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-23  0:00 Nontrivial examples of C interface with Ada gressett
2000-05-24  0:00 ` David Emery
2000-05-24  0:00 ` Ted Dennison
2000-05-24  0:00   ` Marin D. Condic [this message]
2000-05-25  0:00     ` tmoran
2000-05-25  0:00       ` Ted Dennison
2000-05-25  0:00         ` tmoran
2000-05-25  0:00           ` Ted Dennison
2000-05-25  0:00             ` tmoran
2000-05-26  0:00         ` Julian Day
2000-05-26  0:00           ` Julian Day
2000-05-25  0:00       ` Geoff Bull
2000-05-25  0:00         ` tmoran
2000-05-26  0:00       ` Marin D. Condic
2000-05-27  0:00         ` tmoran
2000-05-27  0:00           ` Marin D. Condic
2000-05-28  0:00             ` tmoran
2000-05-28  0:00               ` Marin D. Condic
2000-05-28  0:00                 ` tmoran
2000-05-28  0:00               ` Robert Dewar
2000-05-25  0:00     ` Ted Dennison
2000-05-25  0:00       ` tmoran
2000-05-29  0:00       ` Geoff Bull
2000-05-24  0:00 ` Terry Westley
2000-05-24  0:00 ` tmoran
2000-05-24  0:00 ` Marin D. Condic
2000-05-24  0:00   ` Scott Ingram
2000-05-24  0:00     ` Marin D. Condic
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox