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: <36d51061.1537646@nntp.concentric.net> (raw)
In-Reply-To: 7b2leu$ad$1@nnrp1.dejanews.com

On Thu, 25 Feb 1999 05:01:23 GMT, robert_dewar@my-dejanews.com wrote:

>In article <36d3bf1f.1891152@nntp.concentric.net>,
>  cjrgreen@concentric.net (Christopher Green) wrote:
>> Unchecked conversion of C pointers to Ada access values
>> is, in my experience, no more portable than using address
>> clauses to alias structured types.  When the desired Ada
>> object is an instance of an unconstrained type,
>> converting a pointer is completely nonportable and
>> usually impractical.
>
>and also completely meaningless!

[snip]

Not quite meaningless; if you can construct the compiler-
dependent dope associated with the access value, it
most definitely works.  The result is quite nonportable,
so it is appropriate only where the effort is worthwhile.

This is at best a counterproductive nuisance when
unconstrained array types are involved.  It can often
be made to work when the target of the access type
is a record type with a discriminant, and the discrim-
inant can be located with a record rep spec.

The best example I have involves the X Window
System event type, which is a C union type, but
it has a field that serves as a discriminant.  Code
that handles event types is generally in an inner
loop with tight performance requirements.  The
Ada access type should be to the unconstrained
event record type, not to a constrained subtype.
And copying the event object is incorrect, for some
domain-dependent reasons.

In this case, the best alternative is to construct the
correct access value, using a procedure that may
have to be modified to support different compilers.

-- 
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 ` 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
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 [this message]
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
1999-02-22  0:00 ` Tom Moran
replies disabled

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