* Why isn't this ambiguous?
@ 1997-08-01 0:00 Anonymous
1997-08-02 0:00 ` Robert Dewar
1997-08-02 0:00 ` Robert Dewar
0 siblings, 2 replies; 6+ messages in thread
From: Anonymous @ 1997-08-01 0:00 UTC (permalink / raw)
Here's some code:
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';
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;
With GNAT 3.07/Solaris/Sparc and 3.09/Linux/Pentium, this compiles and
produces this output:
This is Image 1
This is Image 1
2_1
This is Image 1
raised CONSTRAINT_ERROR
I expected the calls to Image to be ambiguous, but GNAT has chosen the
one that returns Character. Anyone able to provide insight?
Jeff Carter PGP:1024/440FBE21
My real e-mail address: ( carter @ innocon . com )
"I blow my nose on you."
Monty Python & the Holy Grail
Posted with Spam Hater - see
http://www.compulink.co.uk/~net-services/spam/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why isn't this ambiguous?
1997-08-01 0:00 Why isn't this ambiguous? Anonymous
1997-08-02 0:00 ` Robert Dewar
@ 1997-08-02 0:00 ` Robert Dewar
1 sibling, 0 replies; 6+ messages in thread
From: Robert Dewar @ 1997-08-02 0:00 UTC (permalink / raw)
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why isn't this ambiguous?
1997-08-01 0:00 Why isn't this ambiguous? Anonymous
@ 1997-08-02 0:00 ` Robert Dewar
1997-08-04 0:00 ` Anonymous
1997-08-02 0:00 ` Robert Dewar
1 sibling, 1 reply; 6+ messages in thread
From: Robert Dewar @ 1997-08-02 0:00 UTC (permalink / raw)
iJeff asked a question about a program with Image and Make functions
and wondered why it was not ambiguous. Something went wrong in the
posting of this message, and the resulting procedure is obviously
syntactically illegal, and furthermore, I cannot guess what it was
supposed to be. Jeff, pleasse repost!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why isn't this ambiguous?
1997-08-02 0:00 ` Robert Dewar
@ 1997-08-04 0:00 ` Anonymous
1997-08-04 0:00 ` Robert A Duff
0 siblings, 1 reply; 6+ messages in thread
From: Anonymous @ 1997-08-04 0:00 UTC (permalink / raw)
<199708011539.RAA04612@basement.replay.com>
On 2 Aug 1997 17:15:50 -0400, dewar@merv.cs.nyu.edu (Robert Dewar)
wrote:
> iJeff asked a question about a program with Image and Make functions
> and wondered why it was not ambiguous. Something went wrong in the
> posting of this message, and the resulting procedure is obviously
> syntactically illegal, and furthermore, I cannot guess what it was
> supposed to be. Jeff, pleasse repost!
>
Yep, sorry, I got some of the code in there twice. I'll try to do better
this time:
Here's some code:
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;
With GNAT 3.07/Solaris/Sparc and 3.09/Linux/Pentium, this compiles and
produces this output:
This is Image 1
This is Image 1
2_1
This is Image 1
raised CONSTRAINT_ERROR
I expected the calls to Image to be ambiguous, but GNAT has chosen the
one that returns Character. Anyone able to provide insight?
Jeff Carter PGP:1024/440FBE21
My real e-mail address: ( carter @ innocon . com )
"I unclog my nose towards you."
Monty Python & the Holy Grail
Posted with Spam Hater - see
http://www.compulink.co.uk/~net-services/spam/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why isn't this ambiguous?
1997-08-04 0:00 ` Anonymous
@ 1997-08-04 0:00 ` Robert A Duff
1997-08-06 0:00 ` Robert Dewar
0 siblings, 1 reply; 6+ messages in thread
From: Robert A Duff @ 1997-08-04 0:00 UTC (permalink / raw)
In article <199708041340.PAA25417@basement.replay.com>,
Anonymous <nobody@REPLAY.COM> wrote:
>I expected the calls to Image to be ambiguous, but GNAT has chosen the
>one that returns Character. Anyone able to provide insight?
I agree that it's ambiguous.
- Bob
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why isn't this ambiguous?
1997-08-04 0:00 ` Robert A Duff
@ 1997-08-06 0:00 ` Robert Dewar
0 siblings, 0 replies; 6+ messages in thread
From: Robert Dewar @ 1997-08-06 0:00 UTC (permalink / raw)
Bob said
<<I agree that it's ambiguous.>>
My newsreader must have lost (or destroyed :-) a post. I still don't have
an example from the original poster that is anywhere near syntactically
correct.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1997-08-06 0:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-01 0:00 Why isn't this ambiguous? Anonymous
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
1997-08-02 0:00 ` Robert Dewar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox