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!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: Re: Beginning Ada Programming, by Andrew T. Shvets (2020) Date: Tue, 3 Dec 2019 21:40:01 +0100 Organization: A noiseless patient Spider Message-ID: References: <87muca3vgd.fsf@nightsong.com> <57d49047-0a61-4d13-8822-d004732a3acc@googlegroups.com> <3b1b248b-43d0-4762-b1f5-1c5460d24c8b@googlegroups.com> <5e222e6c-7afe-4349-ac66-d9b78ca40ec6@googlegroups.com> <27b11294-d628-4118-8328-a4a9a3946937@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 3 Dec 2019 20:40:02 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="e279c7278ab22007bd93fd105c31686d"; logging-data="5854"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194VckE5UL5BiY+CKftlxGm" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 Cancel-Lock: sha1:Ur2VnLGr/Na6IM8V0BpXJupq4Go= In-Reply-To: <27b11294-d628-4118-8328-a4a9a3946937@googlegroups.com> Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:57647 Date: 2019-12-03T21:40:01+01:00 List-Id: Den 2019-12-03 kl. 16:29, skrev Optikos: > > There is a wise middle ground between the 2 extremes between what you & AdaMagica are saying. > > midling) The middle ground is to use a named type* of a predefined** (not range-restricted subtype of) predefined type that represents the problem domain's meaning. Then at a (perhaps much) later time restrict the range of that named type only at the single point of declaration in the package specification, which then takes effect at all points of usage of that named type in other declarations and in the package body without modifying all those points of usage to refer to a different name(d type). Then you lost some/most advantages with declaring such a type, like looping over it, and get exceptions for data outside of the range. To me, that is a major point. Without using the type, why not go for a predefined ? You declare a type to use it as an integral part of your code ('range, 'first, 'last etc) If you put on constraints in a (much) later time, you have won little, you might as well put in asserts instead. -- Björn