comp.lang.ada
 help / color / mirror / Atom feed
From: rds@moss.ATT.COM
Subject: Re: Operator Overloading Resolution
Date: 10 Aug 88 13:05:50 GMT	[thread overview]
Message-ID: <31105@clyde.ATT.COM> (raw)
In-Reply-To: 4548@tikli.tut.fi

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

      reply	other threads:[~1988-08-10 13:05 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
1988-08-09 13:58 ` Matti J{rvinen
1988-08-10 13:05   ` rds [this message]
replies disabled

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