Article View: comp.lang.misc
Article #586Re: Learning Ada
From: William Thomas Wolfe,2847,
Date: Thu, 31 Aug 1989 15:54
Date: Thu, 31 Aug 1989 15:54
39 lines
2332 bytes
2332 bytes
From hutch%citron.cs.clemson.edu@hubcap.clemson.edu (David Hutchens):
> Of course there is the classic (from Ada): "Gee I need the cube of X":
> z := x ** 3;
> which, of course (:-) generates the message "Ambiguous Expression".
>
> The beginning student might be slightly confused by the reason:
> "The constant 3 is overloaded (as both integer and short integer)
> and there are 2 distinct ** operators, so the compiler doesn't
> know which to pick!"
Actually, the compiler does know... the exponentiation operator's
right operand is required to be of type INTEGER, as per Appendix
C, page 2, paragraphs 6 & 7 of ANSI/MIL-STD-1815A:
-- function "**" (LEFT : INTEGER; RIGHT : INTEGER) return INTEGER;
-- An implementation may provide additional predefined integer
-- types... The specification of each operator... for any additional
-- predefined integer type, is obtained by replacing INTEGER by the
-- name of the type in the specification of the corresponding
-- operator of the type INTEGER, except for the right operand
-- of the exponentiating operator.
Similarly, 4.5.6.4 states:
The highest precedence exponentiating operator ** is predefined
for each integer type and for each floating point type. In either
case the right operand, called the exponent, is of the predefined
type INTEGER.
Thus, the constant 3 is not overloaded; it is clearly of type INTEGER.
In view of the fact that the "classic" case described is actually a
double violation of the Ada reference manual, it seems highly probable
that this is an error which is traceable either to the user defining
an unnecessary overloading of "**", or to an unvalidated compiler.
Bill Wolfe, wtwolfe@hubcap.clemson.edu
Technical Details
Message-ID:
<6359@hubcap.clemson.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ukma!gatech!hubcap!billwolf%hazel.cs.clemson.eduReferences:
<6356@hubcap.clemson.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ukma!gatech!hubcap!billwolf%hazel.cs.clemson.edu From: billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu (William Thomas Wolfe,2847,) Newsgroups: comp.lang.misc Subject: Re: Learning Ada Message-ID: <6359@hubcap.clemson.edu> Date: 31 Aug 89 15:54:48 GMT References: <6356@hubcap.clemson.edu> Sender: news@hubcap.clemson.edu Reply-To: billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu Lines: 39