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 10.182.121.170 with SMTP id ll10mr18747156obb.12.1419277135983; Mon, 22 Dec 2014 11:38:55 -0800 (PST) X-Received: by 10.140.27.197 with SMTP id 63mr47284qgx.6.1419277135958; Mon, 22 Dec 2014 11:38:55 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.112.MISMATCH!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!h15no16200386igd.0!news-out.google.com!r1ni76qat.1!nntp.google.com!dc16no1236087qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 22 Dec 2014 11:38:55 -0800 (PST) In-Reply-To: <2430252d-52a1-4609-acef-684864e6ca0c@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=206.53.78.59; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy NNTP-Posting-Host: 206.53.78.59 References: <2430252d-52a1-4609-acef-684864e6ca0c@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: {Pre,Post}conditions and side effects From: sbelmont700@gmail.com Injection-Date: Mon, 22 Dec 2014 19:38:55 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2935 X-Received-Body-CRC: 1254710384 Xref: news.eternal-september.org comp.lang.ada:24196 Date: 2014-12-22T11:38:55-08:00 List-Id: On Monday, December 22, 2014 11:22:29 AM UTC-5, Jean Fran=E7ois Martinez wr= ote: > Perhaps it would have been a good idea to have a No_Side_Effects aspect a= nd only functions labelled with this pragma would be allowed in pre/post co= nditions. Such functions would not be able to modify global variables and = would be restricted to invoking only functions/procedures marked with this = aspect. This is somewhat akin with the restrictions for packages marked w= ith elaboration pragmas or with pragmas realated to distributed system anne= x. In both a package may only with a "lower or equal" package. >=20 It's more than just global variables, though. Your condition might be thus= ly ludicrous: function P return Boolean is x : Some_Ptr_Type :=3D new Integer'(42); begin return True; exception when others =3D> Some_Task.Blocking_Rendezous; end P; Now you've got a function that doesn't access any global variables, but not= only randomly exhaust the heap, but also permanently blocks the thread, so= you are right back where you started. You end up needing all the same rul= es and restrictions as pragma Pure, which means you might as well just be b= eholden to pragma Pure to begin with (or use qualified expressions). But more to the point, there is no escaping that disabling/enabling checks = will cause the program to function differently; that is, after all, the ent= ire point. What constitutes 'correctness' is only in the eyes of the progr= ammer. Ergo: procedure Some_Subprogram is null with Pre =3D> false; procedure Insane is begin Some_Subprogram; raise Program_Error; exception when others =3D> Continue_Running; end Insane; No globals, but it still "breaks" when checks are disabled. -sb