comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: integer questia
Date: Fri, 23 Apr 2010 12:12:46 -0700 (PDT)
Date: 2010-04-23T12:12:46-07:00	[thread overview]
Message-ID: <91a1b503-baf2-4d81-b2cc-afae72f363cf@y3g2000prb.googlegroups.com> (raw)
In-Reply-To: bad42cbb-5c38-4149-a234-981e5c536c53@b23g2000yqn.googlegroups.com

On Apr 23, 2:20 am, bedriemir <bedrie...@gmail.com> wrote:
> Dear Friends,
>
> I will be very happy si quelue'un peut m'éclairer sur....
>
> what is the relation of root_integer , universal_integer and Integer
>
> I think people are arguing on the definiton - in fact very scientific
> -
> in the LM
>
> I am getting different explanations from different sources,
>
> what I have understood is
>
> root_integer is a special definition type , it is not root of
> anything , just implemented for the supression of ambiguities which
> arise with universal_integer, so it should be considered as the base
> type of universal_integer and his operators has the priority over
> universal_integer . Similar situations arise in some other types too.
>
> universal_integer is the base of all integers. it has examplaires in
> integer constants but we can't use its instances. The first operative
> type is Integer . The base type of Integer is universal_integer, the
> first subtype of Integer is itself, then other subtypes may follow...
>
> is it right or  am I missing something ?

You really don't need to know anything about root_integer unless
you're a language lawyer.  root_integer is defined to help get the
overload resolution rules right; without a certain rule in 8.6 that
involves root_integer, some expressions that we don't want to be
ambiguous would be ambiguous and therefore illegal.  So don't worry
about it.

"universal integer" is the implied type of all integer literals, and
the type of named numbers (constants with no type) that have integer
values, e.g.

   A_Thousand : constant := 1000;

The main thing to know about universal integers is that they're
compatible with any other integer type.  So if you declare a procedure
with *any* type of integer parameter, you can use an integer literal
or a named integer number as the parameter when you call it.  Also, if
you see an attribute in the manual that is a function that takes a
universal integer parameter, the actual parameter can be any integer
type (including universal integer).  "universal integer" is an implied
type only, though; you can't declare a variable or anything else as
having that type.

Integer is one of the predefined integer types in Standard (and most
implementations have Short_Integer and/or Long_Integer too).  Those
are the types you can use in your program (unless your organization
has a policy against the standard integer types, which made sense back
in Ada 83 times since there was no guarantee that Integer had to
support any integers larger than 0; in Ada 95+ you can safely use
Integer without worrying about portability if you will never have a
value outside of the range -32767..32767).

Hope this helps,

                           -- Adam







  parent reply	other threads:[~2010-04-23 19:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-23  9:20 integer questia bedriemir
2010-04-23 10:01 ` J-P. Rosen
2010-04-23 19:12 ` Adam Beneschan [this message]
2010-04-26 23:11 ` Robert A Duff
2010-04-27  4:55   ` AdaMagica
replies disabled

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