comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Why isn't this ambiguous?
Date: 1997/08/02
Date: 1997-08-02T00:00:00+00:00	[thread overview]
Message-ID: <dewar.870567976@merv> (raw)
In-Reply-To: 199708011539.RAA04612@basement.replay.com


Here is my best guess at what Jeff Carter meant:

with Ada.Text_Io;

use Ada;
procedure F_Test is
   subtype I_Num is Integer range 1 ..      5;
   subtype O_Num is Integer range 0 .. 99_999;

   function Image (I : I_Num) return Character is
      Img : constant String := Integer'Image (I);
   begin
      Text_Io.Put_Line ("This is Image 1");

      return Img (Img'Last);
   end Image;

   function Make (I : I_Num; O : O_Num) return String is
      function Image (O : O_Num) return String is
         Img : String := Integer'Image (O);
      begin
         Text_Io.Put_Line ("This is Image 2");

         Img (Img'First) := '0';

         if Img'Length > 5 then
            return Img (Img'First + 1 .. Img'Last);
         end if;

         return (1 .. 5 - Img'Length => '0') & Img;
      end Image;
   begin
      return Image (I) & '_' & Image (O);
   end Make;
begin
   Text_Io.Put_Line (Make (2,     1) );
   Text_Io.Put_Line (Make (3, 1_000) );
end F_Test;

If this guess is right, the above program is definitely illegal due to the
ambiguity in the calls to the Image function, since I_Num and O_Num are
the same type.





  reply	other threads:[~1997-08-02  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-08-01  0:00 Why isn't this ambiguous? Anonymous
1997-08-02  0:00 ` Robert Dewar [this message]
1997-08-02  0:00 ` Robert Dewar
1997-08-04  0:00   ` Anonymous
1997-08-04  0:00     ` Robert A Duff
1997-08-06  0:00       ` Robert Dewar
replies disabled

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