On Apr 21, 5:49 pm, Adam Beneschan <a...@[EMAIL PROTECTED]
> wrote:
> > -- (Example C)
> > Z0 : constant := Integer'Last ;
> > type Z is range 0 .. Z0 ;
> > B : constant Z := ( Z0 + 1 ) - 1 ;
> > All the above examples seem to indicate that GNAT, at least, is
> > resolving overloaded addition operators. The overload is between the
> > declared type, root_integer (or something like it), and possibly even
> > universal_integer. With other types, ones where there is no universal
> > type, this would be an illegal ambiguity. So it seems that GNAT is
> > nondeterministically resolving them.
>
> There's nothing nondeterministic about this. See 8.6(29).
I goofed. This rule doesn't actually apply in this case, since the
expected type of the expression is a user-defined integer type, which
isn't compatible with root_integer. (If the expected type of an
expression is a specific integer type that isn't root_integer, the
expression can be of that type or it can be universal_integer, but it
can't be root_integer.) I've sometimes made the mistake of confusing
root_ and universal_integer, and I got sloppy here.
But I think that actually makes the point even moreso that there's no
nondeterminism involved. The expected type is Z; therefore, in
example C, the only possible meaning for "-" is the function that
takes two arguments of type Z and returns Z. That, in turn, applies
to "+". So it's 100% clear from the language rules what functions are
called by this expression. The reason it doesn't raise
Constraint_Error is 4.9(33), as I mentioned earlier.
-- Adam


|