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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Ada case-statement Date: Thu, 15 Mar 2018 17:33:25 +0100 Organization: Adalog Message-ID: References: <365d65ea-5f4b-4b6a-be9b-1bba146394ab@googlegroups.com> NNTP-Posting-Host: vtydEJu0RziDZHka7ZZ6bg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: fr Xref: reader02.eternal-september.org comp.lang.ada:50997 Date: 2018-03-15T17:33:25+01:00 List-Id: Le 15/03/2018 à 16:37, Stephen Davies a écrit : > On Wednesday, 14 March 2018 23:16:29 UTC, Randy Brukardt wrote: > >> declare >> Selector : Day_Type renames Calculate_Day; >> subtype Weekend_Subtype is Day_Type range Sat .. Sun; >> -- Or use a static predicate if the range is discontiguous. >> begin >> case Selector is >> when Mon .. Fri => >> ... >> when Sat | Sun => >> ... >> case Weekend_Subtype'(Selector) is -- A type conversion works, too. >> when Sat => >> ... >> when Sun => >> ... >> end case; >> end case; >> end; > > Unless this has changed in more recent compilers, the static predicate > when Sat & Sun are not contiguous does not work. Gnatpro 7.0.2 complains > about missing values. Also, attempting to use "when Weekend_Subtype" in > the outer case-statement results in complaints about duplicate values. > It IS contiguous in countries where the week starts on Monday... BTW, for you who start the week on Sunday, isn't Sunday part of the week-END? ;-) -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr