From: John Smith <yoursurrogategod@gmail.com>
Subject: What does this code mean?
Date: Wed, 7 Jan 2015 19:53:57 -0800 (PST)
Date: 2015-01-07T19:53:57-08:00 [thread overview]
Message-ID: <68ac5df1-21ab-4b8e-acae-819c78fe8536@googlegroups.com> (raw)
Hello,
I'm working through the wikibook Ada Programming [ https://upload.wikimedia.org/wikipedia/commons/8/8d/Ada_Programming.pdf ]. I came across this example on page 59:
==========================================================
with Ada ;
procedure Convert_Checked is
type Short is range -128 .. +127;
type Byte is mod 256;
package T_IO renames Ada ;
package I_IO is new Ada (Short);
package M_IO is new Ada (Byte);
A : Short := -1;
B : Byte;
begin
B := Byte (A); -- range check will lead to Constraint_Error
T_IO.Put("A = ");
I_IO.Put(Item => A,
Width => 5,
Base => 10);
T_IO.Put(", B = ");
M_IO.Put(Item => B,
Width => 5,
Base => 10);
end Convert_Checked;
==========================================================
And when I compile it, I get this:
==========================================================
% gnatmake -g convert_checked.adb
gcc -c -g convert_checked.adb
convert_checked.adb:13:23: "Ada" is not the name of a generic package
convert_checked.adb:14:23: "Ada" is not the name of a generic package
convert_checked.adb:21:07: "Put" not declared in "Ada"
convert_checked.adb:22:03: "I_IO" is undefined
convert_checked.adb:25:07: "Put" not declared in "Ada"
convert_checked.adb:26:03: "M_IO" is undefined
gnatmake: "convert_checked.adb" compilation error
==========================================================
My question is why is this code written this way? Is it just plain wrong or am I missing some concept that the author(s) tried to get across that I'm missing?
next reply other threads:[~2015-01-08 3:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-08 3:53 John Smith [this message]
2015-01-08 4:37 ` What does this code mean? Shark8
2015-01-08 9:13 ` Simon Wright
2015-01-08 16:44 ` Dirk Heinrichs
2015-01-08 18:42 ` AdaMagica
2015-01-08 18:45 ` AdaMagica
2015-01-10 21:37 ` John Smith
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox