Path: utzoo!utgpu!water!watmath!clyde!rds@moss.ATT.COM
From: rds@moss.ATT.COM
Newsgroups: comp.lang.ada
Subject: Re: Operator Overloading Resolution
Message-ID: <31105@clyde.ATT.COM>
Date: 10 Aug 88 13:05:50 GMT
References: <30740@clyde.ATT.COM> <4548@tikli.tut.fi>
Sender: nuucp@clyde.ATT.COM
Reply-To: rds@moss.UUCP (Richard DeSimine)
Organization: AT&T Bell Laboratories, Whippany NJ
Lines: 38

Hannu-Matti Jarvinen writes:

>>    result := left < -15;
>>--------------------------------------------------------------------
>>The expression -15 is evaluated to be of type INT_SCALAR.
>>
>>Shouldn't this be an ERROR?
>
>Yes, it is.
>
>>DECAda compiles this code without warning, implying the expression -15
>>is an INTEGER type.
>
>No, it does NOT imply expression -15 to be integer. The expression is of
>type universal_integer, which DECAda correctly transforms to the same type than
>variable left.
>
, Tampere University of Technology, Finland
>hmj@tut.fi, hmj@tut.uucp, hmj@tut.funet (tut.ARPA is not the same computer).

INTEGER or universal_integer, it it still ambiguous and in its context
could be construed as an INT_SCALAR or a universal_integer and is,
according to the LRM, illegal. Looking back at the original example,
where the unary operator "-" is overloaded, this would imply that
there is a precedence associated with a predefined and overloaded 
operators. If this is legal, then predefined operators have precedence
over programmer defined operators.

Consider the case where the variable "left" is of type INT_SCALAR and
not of type INTEGER. A compiler should evaluate the expression -15
before resolving the arguments passed to the relational operator "<".

The question really is: should the compiler evaluate the "-" operator
as the predefined unary "-" or the overloaded unary "-".  I say the
expression is ambiguous, and should be an error.

Richard DeSimine (201) 386-2059
AT&T Bell Laboratories, Whippany, New Jersey 07981