comp.lang.ada
 help / color / mirror / Atom feed
* (none)
@ 1989-03-08 13:59 Norman Cohen
  1989-03-10  1:54 ` Implicit Conversion Steven Holtsberg
  0 siblings, 1 reply; 2+ messages in thread
From: Norman Cohen @ 1989-03-08 13:59 UTC (permalink / raw)



Subject: Implicit conversion?

Ref: INFO-ADA Digest Volume 89 Issue 72 (Wed, Mar 8, 1989) Item #4
     (by Steven Holtsberg)

In the example

          with SYSTEM; use SYSTEM;

          procedure example is
            x: tiny_integer;
          begin
            x:= MAX_INT - MAX_INT;
          end example;

the two occurrences of the named number MAX_INT (which are "convertible
universal operands" as defined in RM 4.6(15)) are each converted to type
Tiny_Integer.  The "-" operator thus denotes the subtraction operation
for type Tiny_Integer.

Steven Holtsberg may have read too much into the rule (from RM 4.6(15)),
"An implicit conversion of a convertible universal operand is applied
if and only if the innermost complete context (see 8.7) determines
a unique (numeric) target type for the implicit conversion...."  This
determination can be indirect:  The innermost complete context determines
that the righthand side of the assignment must be of type Tiny_Integer;
since the only visible "-" operator with a result of type Tiny_Integer is
the "-" with operands of that type, the two operands must each be of type
Tiny_Integer; thus the conversion takes place.  In contrast, the complete
context

          Integer_Is_Symmetric: Boolean := Min_Int = -Max_Int;

does not determine a unique target type for a conversion.  Furthermore,
there is a "legal interpretation of this context without ... conversion"
(RM 4.6(15) again), so no conversion takes place.  The unary "-" with
an operand and result of type universal_integer is applied to Max_Int,
and the "=" operator with operands of type universal_integer and a
result of type Boolean is then applied to Min_Int and the result of the
negation.

Norman Cohen

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1989-03-10  1:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1989-03-08 13:59 (none) Norman Cohen
1989-03-10  1:54 ` Implicit Conversion Steven Holtsberg

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