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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Is this a bug in my code or the compiler? Date: Fri, 12 Jun 2015 20:00:11 +0200 Organization: cbb software GmbH Message-ID: <1g33axhwakrzx.o6t14iz4jruy.dlg@40tude.net> References: <4f4cd4b1-0a6d-441b-a4f7-98add70e4e1e@googlegroups.com> <1p71vf5ckbudu$.1qcb9ot1jpysk.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: evoS9sCOdnHjo0GRLLMU1Q.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:26289 Date: 2015-06-12T20:00:11+02:00 List-Id: On Fri, 12 Jun 2015 19:25:00 +0200, G.B. wrote: > On 12.06.15 18:15, Dmitry A. Kazakov wrote: >> Foo (A) and Foo (A) -- Illegal >> Foo (A) and then Foo (A) -- Legal > > C has similar features... So? >> P.P.S. It would become even worse with fine-grained parallelism, as Georg >> keep on suggesting. > > Not sure to what this is referring Parallel evaluation of arguments. > Query-command separation (on objects) seems far better than > functions that make their side effects explicit. You forgot about indefinite return values, which are not available for procedures. The real motivation to have functions with side effects is such return values. > So, in Ada 83, when A is of an access type, That does not change anything because: > Foo (A) and Foo (A) -- Legal Only if A is a constant access. Illegal otherwise. With parallelism atomicity of all immutable operations would additionally be required. Which is why that sort of parallelism is a can of worms. > Moreover, if B and A become pointing to the same object, > > Foo (A) and Foo (B) -- Legal, same effects > > Can a compiler detect this? Easily. Access is logically a referential type which, if properly designed, should be a subtype of the target type. Thus the same rules would apply. If access is meant to be a type of its own, like a pointer in C, then the language should better have no such types. > --- So, you'd be asking for pure > functions? Or total referential transparency? Both. Though purity is not enough for parallelism. A pure function may still get broken under parallel access if not atomic. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de