From: kst@thomsoft.com (Keith Thompson)
Subject: Re: How to print Task_ID type? (GNAT SunOS)
Date: 1996/04/06
Date: 1996-04-06T00:00:00+00:00 [thread overview]
Message-ID: <DpF82v.FBz@thomsoft.com> (raw)
In-Reply-To: dewar.828713391@schonberg
In <dewar.828713391@schonberg> dewar@cs.nyu.edu (Robert Dewar) writes:
[...]
> The method is fine, the test for null is appropriate (I missed that
> in my message before!) The caution is probably unnecessary, I think
> you will find that even in implementations where descriptors etc
> are used, that 'Address is likely to point to the data. Remember
> that X.all is the value of the type, and 'Address will normally
> point to this data.
One would think so, but I just tried an experiment with one
particular Ada 83 compiler. For an object P declared as an access to
unconstrained String, P and P.all'Address have the same value (when
Uncheckedly_Converted to an integer type), but P(P'First)'Address has
a different value. It turns out that P points to a descriptor, and
P(P'First)'Address is the address of the first character of the string
itself.
This should probably (almost certainly) be considered a bug in that
compiler's implementation of P.all'Address, which should be the address
of the string, not of the descriptor.
> You could make doubly sure in the only case
> where there even conceivably could be trouble (arrays), by using
>
> x.all(x'first)'address
Which will raise Constraint_Error if X.all is a null array. For what I
suspect is the most common application for this kind of thing, interfacing
to C, this shouldn't matter, since C doesn't have null arrays (though
future versions of the C standard might). (Incidentally, the ".all" in
the above expression is optional.)
> but at this stage, this is getting a bit junky, so even though it is
> a bit more complexity, it is probably ceaner to instantiate
> address_to_access conversions to get the adress value.
How does Address_To_Access_Conversions help in this case? It only
lets you convert between System.Addess and an access type declared in
Address_To_Access_Conversions; it doesn't provide operations on arbitrary
user-declared access types.
--
Keith Thompson (The_Other_Keith) kst@thomsoft.com
TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718
This sig uses the word "Exon" in violation of the Communications Decency Act.
next prev parent reply other threads:[~1996-04-06 0:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-04-03 0:00 How to print Task_ID type? (GNAT SunOS) Greg Bond
1996-04-04 0:00 ` Robert Dewar
1996-04-04 0:00 ` Greg Bond
1996-04-04 0:00 ` Greg Bond
1996-04-05 0:00 ` Keith Thompson
1996-04-05 0:00 ` Greg Bond
1996-04-05 0:00 ` Robert Dewar
1996-04-06 0:00 ` Keith Thompson [this message]
1996-04-06 0:00 ` Robert Dewar
1996-04-07 0:00 ` Keith Thompson
1996-04-05 0:00 ` Robert Dewar
1996-04-05 0:00 ` Laurent Guerby
1996-04-04 0:00 ` Joel Sherrill
1996-04-06 0:00 ` Fergus Henderson
1996-04-06 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox