comp.lang.ada
 help / color / mirror / Atom feed
From: wayne@inmet.UUCP
Subject: Re: Operator Overloading Resolution
Date: 8 Aug 88 14:20:00 GMT	[thread overview]
Message-ID: <124000015@inmet> (raw)
In-Reply-To: 30740@clyde.ATT.COM



> /* Written  1:59 pm  Aug  4, 1988 by rds@moss.ATT.COM in inmet:comp.lang.ada */
> /* ---------- "Operator Overloading Resolution" ---------- */
> The following code segment was compiled using Telesoft 3.15.
 
  ...
> The expression -15 is evaluated to be of type INT_SCALAR.

> Shouldn't this be an ERROR?

No. DEC-Ada is correct, Telesoft is in error.  The expression "15"
is of course of type UNIVERSAL_INTEGER.  According to LRM 4.10 and 
LRM 4.16:15 the subexpression "-15" is therefore also of universal
integer, regardless of a function definition.  It is then implicitly
converted to INTEGER (LRM 4.6:15) when evaluating the rest of the
expression because "left" is defined to be of INTEGER and a "<" is
available with two INTEGER parameters which returns BOOLEAN.

It can be assumed that if it possible for a subexpression to be of
type universal expression, it will be of type universal expression.
If you wish to use your definition of the negation operator, you
must qualifiy the 15 to be of type INT_SCALAR , such as in

     result := left < - INT_SCALAR'(15);

then it will be ambiguous, because there is no "<" defined to take
both an INTEGER and an INT_SCALAR.  Don't forget to initialize 
"left" or you may get an exception at run_time.     

Wayne Wylupski
Intermetrics, Inc.
Cambridge, MA

  reply	other threads:[~1988-08-08 14:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-08-04 17:59 Operator Overloading Resolution rds
1988-08-08 14:20 ` wayne [this message]
1988-08-09 13:58 ` Matti J{rvinen
1988-08-10 13:05   ` rds
replies disabled

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