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!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Beginning Ada Programming, by Andrew T. Shvets (2020) Date: Fri, 6 Dec 2019 18:47:05 -0600 Organization: JSA Research & Innovation 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> <80bcdfd1-b1e5-4ebf-aa8a-4beaba5ec3c2@googlegroups.com> <60e61003-409d-4bd5-9784-8ddad5942934@googlegroups.com> <4f659af6-c840-4509-9f76-e9a96b547a55@googlegroups.com> Injection-Date: Sat, 7 Dec 2019 00:47:06 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="2743"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:57679 Date: 2019-12-06T18:47:05-06:00 List-Id: "Shark8" wrote in message news:b08cad8b-eea0-435d-8058-19321affe42c@googlegroups.com... ... >Example: >Function Copy( Object : Password ) return Password is (Object); >We know that passing in parameter object, the item must be conformant to >Password [checked on call) and so can copy and pass out the Password >without checking its validity... MORE, given a variable X --X : >Password:= Create_Password("ThisPassword#1!")-- we know that X must >conform to the definition, so then Y : Password:= Copy( X ); needn't make >any check at all. Such an optimization is not true in the most general case, since the predicate might have a side effect or have its result changed by some side effect of another operation. In this case, of course, it could be done. There's a rule that implies that predicates (and other assertions) that change values when only assertion expressions are being evaluated can be rejected (and thus aren't portable), but that does not apply if some other operation occurs in between the evaluations (such as the call to Copy here). Randy. Randy.