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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx26.iad.POSTED!not-for-mail From: Shark8 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:36.0) Gecko/20100101 Thunderbird/36.0a1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: What does this code mean? References: <68ac5df1-21ab-4b8e-acae-819c78fe8536@googlegroups.com> In-Reply-To: <68ac5df1-21ab-4b8e-acae-819c78fe8536@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Thu, 08 Jan 2015 04:37:11 UTC Organization: TeraNews.com Date: Wed, 07 Jan 2015 21:37:08 -0700 X-Received-Bytes: 1887 X-Received-Body-CRC: 3478176026 Xref: news.eternal-september.org comp.lang.ada:24470 Date: 2015-01-07T21:37:08-07:00 List-Id: On 07-Jan-15 20:53, John Smith wrote: > > 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? > I think it's wrong -- the "package I_IO is new Ada (Short);" is syntax for instantiating a generic package... noticing the space-comma, I think there might have been a transcription error -- it is likely this is what was meant: With Ada.Text_IO; procedure Convert_Checked is type Short is range -128 .. +127; type Byte is mod 256; package T_IO renames Ada.Text_IO; package I_IO is new Ada.Text_IO.Integer_IO (Short); package M_IO is new Ada.Text_IO.Modular_IO (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;