comp.lang.ada
 help / color / mirror / Atom feed
From: cjrgreen@concentric.net (Christopher Green)
Subject: Re: Alternate to Unchecked_Conversion - Portable?
Date: 1999/02/24
Date: 1999-02-24T00:00:00+00:00	[thread overview]
Message-ID: <36d50d18.695962@nntp.concentric.net> (raw)
In-Reply-To: 7b2l6s$vu3$1@nnrp1.dejanews.com

On Thu, 25 Feb 1999 04:57:04 GMT, robert_dewar@my-dejanews.com wrote:

>In article <36d3ba85.713118@nntp.concentric.net>,
>  cjrgreen@concentric.net (Christopher Green) wrote:
>> In
>> this case, it is natural enough, though not fully
>> portable, to declare an Ada array of the actual
>> size and map it onto the C array with an address
>> clause.
>
>In Ada 83, this is ALWAYS an incorrect approach, because
>it is erroneous, which means the compiler need make no
>attempt at all (e.g. in suppressing optimziation) to
>make this "work".

Such compilers (there are a few still in use) are, for reasons
like this, virtually useless for the sort of programming in which
address clauses, Unchecked_Conversion, or equivalence
between C pointer types and Ada access types is important.

Theoretical correctness and actual correct operation are
different things.  There are many compilers on which the
address clause mapping does work as it "should".

>> In Ada 95, the package Interfaces.C.Pointers is
>> a better solution to this kind of problem.
>
>If you look at the implementation of this package, it
>will almost certainly use unchecked conversion on pointers!

True; however, the level of abstraction in using
Interfaces.C.Pointers is higher, and the reduction
in programming effort and improvement in port-
ability may be worth any trade in efficiency.

Furthermore, if the Unchecked_Conversions
internal to the Interfaces.C.Pointers package
don't do the right thing, you can at least blame
the compiler vendor.  If you code Unchecked_
Conversions on your own and they don't do the
right thing on the platforms you must support,
you're stuck.

>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

-- 
Chris Green
Advanced Technology Center
Laguna Hills, California





  reply	other threads:[~1999-02-24  0:00 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-21  0:00 Alternate to Unchecked_Conversion - Portable? Steve Doiel
1999-02-21  0:00 ` Matthew Heaney
1999-02-21  0:00 ` Steve Quinlan
1999-02-22  0:00   ` robert_dewar
1999-02-22  0:00 ` Tom Moran
1999-02-22  0:00 ` Christopher Green
1999-02-23  0:00   ` Matthew Heaney
1999-02-23  0:00     ` Samuel Mize
1999-02-24  0:00     ` robert_dewar
1999-02-25  0:00       ` Nick Roberts
1999-02-25  0:00         ` robert_dewar
1999-02-26  0:00           ` Nick Roberts
1999-02-26  0:00             ` Matthew Heaney
1999-02-27  0:00               ` Nick Roberts
1999-02-24  0:00   ` robert_dewar
1999-02-23  0:00     ` Christopher Green
1999-02-25  0:00       ` robert_dewar
1999-02-24  0:00         ` Christopher Green [this message]
1999-02-25  0:00           ` robert_dewar
1999-02-25  0:00             ` dennison
1999-02-25  0:00               ` Christopher Green
1999-02-26  0:00                 ` robert_dewar
1999-02-26  0:00                   ` Christopher Green
1999-03-01  0:00                     ` Nick Roberts
1999-03-01  0:00                       ` dewar
1999-03-01  0:00                         ` Nick Roberts
1999-02-26  0:00                 ` Tom Moran
1999-02-26  0:00                   ` robert_dewar
1999-02-26  0:00             ` Robert A Duff
1999-02-28  0:00               ` robert_dewar
1999-02-23  0:00     ` Christopher Green
1999-02-25  0:00       ` robert_dewar
1999-02-24  0:00         ` Christopher Green
1999-02-25  0:00           ` robert_dewar
1999-02-26  0:00             ` Dale Stanbrough
1999-02-26  0:00               ` Robert A Duff
1999-02-22  0:00 ` robert_dewar
1999-02-22  0:00   ` Samuel Mize
replies disabled

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