comp.lang.ada
 help / color / mirror / Atom feed
From: jhassett@my-dejanews.com
Subject: Re: Incompatibility involving universal expressions
Date: 1998/10/12
Date: 1998-10-12T00:00:00+00:00	[thread overview]
Message-ID: <6vt19c$2iq$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 6vj3sb$k7c$1@nnrp1.dejanews.com



Last week I posted a message about what I thought was an Ada 83/
Ada 95 incompatibility I'd run into, and asking if someone could
set me straight if I'd misunderstood the situation.

It seems that everyone who bothered to read my message was either
too busy or too kind to embarrass me with a response, so I'm
responding to myself, in case any reader might still be confused.

The incompatibility does not exist.  The details mainly concern
my creative misunderstanding of RM83.

I had complained that the following little package spec compiled
under the Rational VADS Ada 83 compiler, but not under the Green
Hills Ada 95 compiler:

with Text_IO;
package P is
  N : constant := 10;
  type T is new Text_IO.Count range 2 .. N - 1;
end P;

I'm now convinced that the VADS compiler was in error: the use of
"N - 1" above is illegal in both versions of Ada.  I had thought
that this expression could be implicitly converted from
universal_integer to Text_IO.Count in Ada 83, but not in Ada 95.
In fact, it cannot be implicitly converted in either language.

What I missed was a proper interpretation of this restriction from
RM83-4.6(15):

   An implicit conversion of an operand of type universal_integer
   to another integer type . . . can only be applied if the
   operand is either a numeric literal, a named number, or an
   attribute

In other words, more general universal_integer expressions such as
"N - 1" are not subject to implicit conversion.

I had read the paragraph containing the quoted restriction, but I
think I dismissed it with too narrow an interpretation of the word
"operand" (which doesn't seem to be defined in RM83).  Without much
thought, I took this to refer only to actual parameters of
subprograms, so I didn't see it as relevant to a bound of a range.
(It still isn't clear to me why the quoted restriction uses the
word "operand" instead of "expression".)

In any event, I'm happy to find that the supposed incompatibility
is not real, but I'm chagrined at having been so misled by a faulty
compiler.

- Jim Hassett

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




  reply	other threads:[~1998-10-12  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-08  0:00 Incompatibility involving universal expressions jhassett
1998-10-12  0:00 ` jhassett [this message]
1998-10-12  0:00   ` Tucker Taft
replies disabled

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