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 X-Received: by 2002:ac8:7282:: with SMTP id v2mr5842806qto.75.1575392566478; Tue, 03 Dec 2019 09:02:46 -0800 (PST) X-Received: by 2002:a9d:68ca:: with SMTP id i10mr3834175oto.178.1575392566253; Tue, 03 Dec 2019 09:02:46 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!g89no1815517qtd.0!news-out.google.com!w29ni93qtc.0!nntp.google.com!g89no1815509qtd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 3 Dec 2019 09:02:46 -0800 (PST) In-Reply-To: <60e61003-409d-4bd5-9784-8ddad5942934@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.2.231 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <4f659af6-c840-4509-9f76-e9a96b547a55@googlegroups.com> Subject: Re: Beginning Ada Programming, by Andrew T. Shvets (2020) From: Shark8 Injection-Date: Tue, 03 Dec 2019 17:02:46 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:57641 Date: 2019-12-03T09:02:46-08:00 List-Id: On Tuesday, December 3, 2019 at 9:50:40 AM UTC-7, Lucretia wrote: >=20 > I said to introduce them to typing concepts after getting them used to th= e very basics, i.e. first few simple programs adding numbers and printing t= hem out, how the build using the compiler, then handle types and explaining= how they're different to something like typedef in C. 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 modeli= ng 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 =3D> Symbol in '!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'; Minimum_Length : Constant :=3D 8; Maximum_Length : Constant :=3D 32; Type Password is new String with Dynamic_Predicate =3D> Password'Length in Minimum_Length..Maximum_Le= ngth=20 and (For all C of Password =3D> C in Digit|Upper_Case|Lower_Case|Symbol= ); You can then explain what each of these are ans how they compose the type P= assword that is guaranteed by the type-system to have the modeled propertie= s.