Universal Integer in TO_ADDRESS call 
Author Message
 Universal Integer in TO_ADDRESS call

I am trying to do a TO_ADDRESS type conversion while using XDADA. The two
parameter types supported by the compiler are {universal integer} and
ADDRESS_INT.

ADDRESS_INT is too short to be used and universal integer relies on  the
parameter being a named-number.

The existing code uses named numbers as constants without types in the
declaration. They of course adopt the universal integer and everything is
fine.

I need to modify the code and add offsets taken from an array to this value
and the compiler doesn't like it because the parameter is no longer of type
universal-integer. The way I understand it is that universal integer applies
to named-numbers only. Is it possible to declare any array of constants
which will adopt the universal integer type ? Or can anyone help with an
alternative ?

Any help much appreciated
Dave Akister



Wed, 14 Nov 2001 03:00:00 GMT  
 Universal Integer in TO_ADDRESS call


Quote:
> I am trying to do a TO_ADDRESS type conversion while using
> XDADA. The two parameter types supported by the compiler are
> {universal integer} and ADDRESS_INT.

Note that the use of universal integer here is a language
extension. In my opinion, a significant enough one that I
would hesitate to sign a declaration of conformance (it is
one place where GNAT refused to be exactly DEC Ada compatible)

Quote:
> ADDRESS_INT is too short to be used and universal integer
> relies on  the parameter being a named-number.

> The existing code uses named numbers as constants without
> types in the declaration. They of course adopt the universal
> integer and everything is fine.

> I need to modify the code and add offsets taken from an array
> to this value and the compiler doesn't like it because the
> parameter is no longer of type universal-integer.

There is absolutely no way to solve this problem. Are you sure
that there is not another version of To_Address that takes a
longer integer? That is certainly the way it works on DEC Ada
83. The universal integer bogosity is there only to allow
unqualified constants to be used without causing ambiguities.

If you have a compiler where the ONLY form with full range is
universal integer, then that is a rather bad limitation I
would say, since as you have found out, there is no way around
it. Universal integer is not a first class citizen in the type
structure of Ada!

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Wed, 14 Nov 2001 03:00:00 GMT  
 Universal Integer in TO_ADDRESS call
the 'conversion' to universal integer is as follows:

        Integer'Pos (X)

Hope it pulls the trick for you ;-) ...

Regards

Vincent Amiot / Aonix


Quote:
> I am trying to do a TO_ADDRESS type conversion while using XDADA. The two
> parameter types supported by the compiler are {universal integer} and
> ADDRESS_INT.

> ADDRESS_INT is too short to be used and universal integer relies on  the
> parameter being a named-number.

> The existing code uses named numbers as constants without types in the
> declaration. They of course adopt the universal integer and everything is
> fine.

> I need to modify the code and add offsets taken from an array to this
value
> and the compiler doesn't like it because the parameter is no longer of
type
> universal-integer. The way I understand it is that universal integer
applies
> to named-numbers only. Is it possible to declare any array of constants
> which will adopt the universal integer type ? Or can anyone help with an
> alternative ?

> Any help much appreciated
> Dave Akister



Thu, 15 Nov 2001 03:00:00 GMT  
 Universal Integer in TO_ADDRESS call


Quote:
> the 'conversion' to universal integer is as follows:

>    Integer'Pos (X)

> Hope it pulls the trick for you ;-) ...

> Regards

> Vincent Amiot / Aonix

Right, I missed this possibility, but Vincent is absolutely
right, this should work. It is very peculiar code, hard to
imagine any normal Ada situation where one would want this
conversion, but here it may be just the ticket. Note that
you can do this with any integer type.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Thu, 15 Nov 2001 03:00:00 GMT  
 Universal Integer in TO_ADDRESS call
Thanks very much for that chaps.
It does seem bizarre that address conversion on this XDADA compiler is
limited to an short integer type - which is too small for most applications,
and the universal type which loses it universalness (made up word!) when
manipulated in any way....
Oh well INTEGER'POS it is then. DEC ADA which is the host compiler is more
fun with its UNSIGNED_LONGWORD.
Thanks a lot
--
David Akister
Wellgate Technology Ltd
Software Development & Computer Book Specialist

Quote:


> > the 'conversion' to universal integer is as follows:

> > Integer'Pos (X)

> > Hope it pulls the trick for you ;-) ...

> > Regards

> > Vincent Amiot / Aonix

> Right, I missed this possibility, but Vincent is absolutely
> right, this should work. It is very peculiar code, hard to
> imagine any normal Ada situation where one would want this
> conversion, but here it may be just the ticket. Note that
> you can do this with any integer type.

> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.



Thu, 15 Nov 2001 03:00:00 GMT  
 Universal Integer in TO_ADDRESS call


Quote:
> Thanks very much for that chaps.
> It does seem bizarre that address conversion on this XDADA
compiler is
> limited to an short integer type - which is too small for most
applications,
> and the universal type which loses it universalness (made up
word!) when
> manipulated in any way....
> Oh well INTEGER'POS it is then. DEC ADA which is the host
compiler is more
> fun with its UNSIGNED_LONGWORD.
> Thanks a lot

Sounds like the result of a rather bizarre subsetting of the
original DEC Ada 83 design. After all the only reason for
the universal_integer trick in DEC Ada 83 is to get around
the ambiguities that are introduced by having the function
defined on two different integer types.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Fri, 16 Nov 2001 03:00:00 GMT  
 Universal Integer in TO_ADDRESS call

Quote:

> I am trying to do a TO_ADDRESS type conversion while using XDADA. The two
> parameter types supported by the compiler are {universal integer} and
> ADDRESS_INT.

> ADDRESS_INT is too short to be used and universal integer relies on  the
> parameter being a named-number.

> The existing code uses named numbers as constants without types in the
> declaration. They of course adopt the universal integer and everything is
> fine.

> I need to modify the code and add offsets taken from an array to this value
> and the compiler doesn't like it because the parameter is no longer of type
> universal-integer. The way I understand it is that universal integer applies
> to named-numbers only. Is it possible to declare any array of constants
> which will adopt the universal integer type ? Or can anyone help with an
> alternative ?

> Any help much appreciated

One trick I use from time to time is T'Pos, which turns a specific
integer type into universal int.  I don't know if it will help you here,
though.


Thu, 22 Nov 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Universal integer or universal expression

2. Universal integer or what?

3. ? universal integer (and/or other types)

4. Type conversion from Universal Integer

5. Universal Disassemblers vs. Universal MIILs

6. universal joins, universal stransmission shaft

7. Call for Content (Universal Media)

8. Silos: Integers in functions values persist between calls.

9. embedded python: "integer is required", when calling PyRun_SimpleString

10. Near Final PEP 237 - Unifying Long Integers and Integers

11. Revised PEP 237 - Unifying Long Integers and Integers

12. integer/integer division

 

 
Powered by phpBB® Forum Software