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: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: Beginning Ada Programming, by Andrew T. Shvets (2020) Date: Fri, 13 Dec 2019 20:21:52 -0800 Organization: None to speak of Message-ID: <87d0crwn8f.fsf@nosuchdomain.example.com> 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> <80bcdfd1-b1e5-4ebf-aa8a-4beaba5ec3c2@googlegroups.com> <60e61003-409d-4bd5-9784-8ddad5942934@googlegroups.com> <4f659af6-c840-4509-9f76-e9a96b547a55@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="afe4f81491710b06fe17e3faf394c455"; logging-data="28634"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T4BBE0O9P0/S4QMN1vxoe" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:pHNXN8JZFDHIh8tD6fNTEKm25xs= sha1:pdmRYS/ert5dg9fAmPv2uYpVakk= Xref: reader01.eternal-september.org comp.lang.ada:57727 Date: 2019-12-13T20:21:52-08:00 List-Id: Shark8 writes: > On Thursday, December 5, 2019 at 9:36:00 AM UTC-7, Dirk Heinrichs wrote: >> Am 03.12.19 um 18:02 schrieb Shark8: >> >> > Perhaps the easiest way to do this is by doing something that's >> > (e.g.) much more complex in C, but relatively straightforward in >> > Ada -- perhaps modeling a Password in the software: >> > >> > Type Digit is Character Range '0'..'9'; >> > Type Upper_Case is Character Range 'A'..'Z'; >> > Type Lower_Case is Character Range 'a'..'z'; >> > Type Symbol is Character >> > with Static_Predicate => Symbol in '!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'; >> > >> > Minimum_Length : Constant := 8; >> > Maximum_Length : Constant := 32; >> > >> > Type Password is new String >> > with Dynamic_Predicate => Password'Length in Minimum_Length..Maximum_Length >> > and (For all C of Password => C in Digit|Upper_Case|Lower_Case|Symbol) >> > and Password(Password'First) Lower_Case; >> >> That's a really nice one. How would the predicate look like if the PW >> was to start with a lowercase character? > See the modification. Don't those 4 types need to be subtypes? -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com [Note updated email address] Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */