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!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx15.iad.POSTED!not-for-mail From: Brad Moore User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: {Pre,Post}conditions and side effects References: <2430252d-52a1-4609-acef-684864e6ca0c@googlegroups.com> <877fxi58yp.fsf@mid.deneb.enyo.de> In-Reply-To: <877fxi58yp.fsf@mid.deneb.enyo.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 68.145.219.148 X-Complaints-To: internet.abuse@sjrb.ca X-Trace: 1419396076 68.145.219.148 (Wed, 24 Dec 2014 04:41:16 UTC) NNTP-Posting-Date: Wed, 24 Dec 2014 04:41:16 UTC Date: Wed, 24 Dec 2014 04:41:16 -0700 X-Received-Bytes: 2448 X-Received-Body-CRC: 4030872556 Xref: news.eternal-september.org comp.lang.ada:24216 Date: 2014-12-24T04:41:16-07:00 List-Id: On 2014-12-23 2:53 PM, Florian Weimer wrote: > * Brad Moore: > >> There is a proposal to have a Global aspect to be considered for Ada >> 202x, that could be applied to subprograms. Such an aspect would >> indicate if a subprogram body referenced any global variables. It >> would also indicate if a subprogram references no globals. >> >> eg. >> function Foo (X : Integer) return Integer >> with Globals => null; >> >> I believe such a subprogram would not have side-effects > > It could still call subprograms which modify global variables, or use > its arguments to modify global state. Not with our proposal, because the idea is that the compiler would not allow one to apply "with Globals => null" to a subprogram, if it in turn called any subprograms that did not also have "with Globals => null" in its contract. > > Even if you solve this (different, quite feasible approaches exist), > (lack of) termination of the evaluation of conditions would still be a > visible side effect, and that's more difficult to tackle. > Yes, I suppose it is impossible to have any function that truly has no side effects. They all use cycles of the CPU, which could be viewed as side effect, since that is a shared resource. The elapsing of time is another side effect that cant be eliminated, and any processing of pre and post conditions can impact both of these side effects. I think these may have been be finer grained side effects that the original poster was concerned about though. Brad