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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ce0900b60ca3f616 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-05 08:33:58 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: dmitry@elros.cbb-automation.de (Dmitry A. Kazakov) Newsgroups: comp.lang.ada Subject: Re: Side-Effects in Functions [Rosen Trick] Date: Mon, 05 Nov 2001 16:33:53 GMT Message-ID: <3be6b6c9.26855093@News.CIS.DFN.DE> References: <9rti6v$hcu$1@news.huji.ac.il> <1EyE7.10050$xS6.13527@www.newsranger.com> <9rue9f$j4t$1@nh.pace.co.uk> <9ruiet$kqg$1@nh.pace.co.uk> <3BE3235D.E292B890@boeing.com> <3BE35498.9F6381A2@acm.org> <9s230d$107b5a$2@ID-25716.news.dfncis.de> <5ee5b646.0111040507.5ca7ea23@posting.google.com> <9s3tl3$111hco$1@ID-25716.news.dfncis.de> <5ee5b646.0111041846.93f3e07@posting.google.com> <9s5eub02j61@drn.newsguy.com> <3be666fe.6426140@News.CIS.DFN.DE> <9s5skb09lv@drn.newsguy.com> <3be6a7a3.22977140@News.CIS.DFN.DE> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) X-Trace: fu-berlin.de 1004978014 32919847 212.79.194.111 (16 [77047]) X-Newsreader: Forte Free Agent 1.21/32.243 Xref: archiver1.google.com comp.lang.ada:15819 Date: 2001-11-05T16:33:53+00:00 List-Id: On Mon, 5 Nov 2001 15:21:13 +0000 (UTC), Preben Randhol wrote: >On Mon, 05 Nov 2001 14:59:15 GMT, Dmitry A. Kazakov wrote: >> On 5 Nov 2001 03:19:39 -0800, pete@nospam >> wrote: >> >> procedure Find (Folder : in out Table) return Table_Token; >> >> with >> >> procedure Find (Folder : in out Table; Result : out Table_Token); >> >> The difference between them is rather syntactical. Semantically they > >Yes and I don't understand why you want it. What if you expect to change >two wariables in the procedure like: > >procedure Find (Folder : in out Table; Result : out Table_Token; > Unique : out Boolean); Well, multiple results is another story. Some languages have return tuples, but I am not convinced that Ada really needs it. Then your argument could be well applied to pure functions as well. Why not to replace them by procedures with an extra out parameter? A bit more work with temporal variables, unability to initialize constants, but generally no problem (:-)) >to do it like: > >procedure Find (Folder : in out Table; Unique : out Boolean) return Table_Token; > >looks a bit messy I think. Yes. But I still have a choice to make it: procedure Find (Folder : in out Table; Result : out Table_Token; Unique : out Boolean); It is of course not so that any out parameter has to be declared as the result. All we need is an impure function. As Robert have pointed, it is ridiculous to have an ability to write impure functions and have no right to manifest them as such (openly using in out parameters). If the word "function" makes people so sensitive, let's use "procedure" instead! >What is the difference between a function with in out and a procedure >with a return value? It amounts to the same thing I think. There is no difference other than functions with in out parameters are unacceptable for some part of Ada community, which is enough powerful to ban them forever (:-)). P.S. I do not belong to this part. Regards, Dmitry Kazakov