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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: quiz for Sequential_IO Read Date: Sun, 3 Sep 2017 15:44:53 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 3 Sep 2017 13:40:28 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="ed445aea6c6564df148c8dd697e7867b"; logging-data="14574"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7LjtS9B3HQ51BYvaGPzKKaj60nC6iPWA=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 In-Reply-To: Content-Language: en-US Cancel-Lock: sha1:Wtdl5mTXOGWxxJdk6DbbTgEfUVg= Xref: news.eternal-september.org comp.lang.ada:47915 Date: 2017-09-03T15:44:53+02:00 List-Id: On 09/03/2017 02:47 PM, Frank Buss wrote: > > Why is it a signed type? The range says only 0..255, and in fact, I can write this: > > type Byte is range 0..255; for Byte'Size use 8; > > and it works as expected. It's signed because the language definition says it's signed. All types declared with range are signed. See ARM 3.5.4 http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-3-5-4.html for the gory details. If you don't specify 'Size, then the compiler uses the 'Size for the base type. If you specify the size it will use that instead. Realistically, stand-alone objects will always use complete bytes to store a value, and Sequential_IO will read and write that number of bytes. So without a Size clause, Sequential_IO read 2 bytes, and with it, only 1. -- Jeff Carter "Oh Lord, bless this thy hand grenade, that with it thou mayst blow thine enemies to tiny bits, in thy mercy." Monty Python and the Holy Grail 24