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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a37:aa45:: with SMTP id t66mr15885010qke.218.1575666340633; Fri, 06 Dec 2019 13:05:40 -0800 (PST) X-Received: by 2002:a9d:eee:: with SMTP id 101mr3011262otj.5.1575666340404; Fri, 06 Dec 2019 13:05:40 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!g89no888318qtd.0!news-out.google.com!w29ni312qtc.0!nntp.google.com!g89no888310qtd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 6 Dec 2019 13:05:40 -0800 (PST) In-Reply-To: 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> <4f659af6-c840-4509-9f76-e9a96b547a55@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Beginning Ada Programming, by Andrew T. Shvets (2020) From: Shark8 Injection-Date: Fri, 06 Dec 2019 21:05:40 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:57677 Date: 2019-12-06T13:05:40-08:00 List-Id: On Friday, December 6, 2019 at 1:29:57 PM UTC-7, Jeffrey R. Carter wrote: > On 12/6/19 7:34 PM, Shark8 wrote: > >>> > >>> Type Password is new String > >>> with Dynamic_Predicate =3D> Password'Length in Minimum_Length..Ma= ximum_Length > >>> and (For all C of Password =3D> C in Digit|Upper_Case|Lower_Cas= e|Symbol) > >>> and Password(Password'First) Lower_Case; >=20 > It looks like you left out an "in". >=20 > I bet the coders among us are having heart attacks about the "inefficienc= y" of=20 > checking the first character twice. I'd be interested in hearing from com= piler=20 > writers whether their optimizers would optimize that. Why? Seriously, why worry about inefficiency at this level? Almost all your obse= rvable problems are going to be algorithmic, and attaching assertions to a = type allows for optimizations. Example: Function Copy( Object : Password ) return Password is (Object); We know that passing in parameter object, the item must be conformant to Pa= ssword [checked on call) and so can copy and pass out the Password without = checking its validity... MORE, given a variable X --X : Password:=3D Create= _Password("ThisPassword#1!")-- we know that X must conform to the definitio= n, so then Y : Password:=3D Copy( X ); needn't make any check at all.