From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.189.198 with SMTP id c46mr5180763yhn.12.1420689237525; Wed, 07 Jan 2015 19:53:57 -0800 (PST) X-Received: by 10.140.91.40 with SMTP id y37mr822qgd.11.1420689237489; Wed, 07 Jan 2015 19:53:57 -0800 (PST) Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!dc16no302024qab.1!news-out.google.com!m7ni9qag.1!nntp.google.com!dc16no302022qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 7 Jan 2015 19:53:57 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=50.138.174.211; posting-account=AvekzAoAAABj-TclKcOWQmXwA49MFPGX NNTP-Posting-Host: 50.138.174.211 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <68ac5df1-21ab-4b8e-acae-819c78fe8536@googlegroups.com> Subject: What does this code mean? From: John Smith Injection-Date: Thu, 08 Jan 2015 03:53:57 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.giganews.com comp.lang.ada:191773 Date: 2015-01-07T19:53:57-08:00 List-Id: 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?