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.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5265ce03ee8f5252 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-05 01:02:04 PST Path: supernews.google.com!sn-xit-03!supernews.com!news-feed.riddles.org.uk!arclight.uoregon.edu!newsfeed.mathworks.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: n_brunot@my-deja.com Newsgroups: comp.lang.ada Subject: Re: Ok sorry, it is just a book gives no feedback. Date: Fri, 05 Jan 2001 08:53:06 GMT Organization: Deja.com Message-ID: <93421h$2ju$1@nnrp1.deja.com> References: <931r2l$4ai5t$2@ID-25716.news.dfncis.de> <931t08$5u5$1@nnrp1.deja.com> <932632$e0e$1@nnrp1.deja.com> <932an8$ijs$1@nnrp1.deja.com> NNTP-Posting-Host: 212.27.42.154 X-Article-Creation-Date: Fri Jan 05 08:53:06 2001 GMT X-Http-User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; fr-FR; m18) Gecko/20001106 Netscape6/6.0 X-Http-Proxy: 1.1 x51.deja.com:80 (Squid/1.1.22) for client 212.27.42.154 X-MyDeja-Info: XMYDJUIDn_brunot Xref: supernews.google.com comp.lang.ada:3669 Date: 2001-01-05T08:53:06+00:00 List-Id: In article <932an8$ijs$1@nnrp1.deja.com>, Robert Dewar wrote: > In article <932632$e0e$1@nnrp1.deja.com>, > n_brunot@my-deja.com wrote: > > Just look the following code (simplified from old buggy code). > This would be horrible code even if procedures were used. > Global variables in general are harmful if not very carefully > used. Exactly, that's right. :-) I found this kind of code in several years old code which worked perfectly well until compiled on a compiler differently evaluating "&". When you have a big project with more than 1 million lines code, it's unrealistic to assume that this kind of thing is impossible. Assuming that one single person, however genius he is, can check every single line code, and cannot make mistakes is totally unrealistic and dangerous. Therefore simple rules like - yes, avoid side effects when you can - no, don't avoid them if you cannot :-) (Is it necessary to say such an evidence ...) - test your code on different compilers (you'll have more chances to detect bugs which could remain unnoticed because of specific behavior of one compiler) are wise and don't bring any restriction > You argue that functions should not have side effects. Yes, when you can avoid it, avoid it :-) No, nobody said that side effects are forbidden, look at previous posts ... > point is that there are plenty of legitimate functions that > have side effects in the sense in which they were defined > here. Yes, nobody denied that, and nobody said it's bad :-) > E.g. A function that takes two pointers to strings and returns > a pointer to their concatenation is quite reasonable, but has > side effects according to this definition. > Note that ANY allocation has a side effect, so these rules > about > functions would say that no functions can ever do allocations. > That's an unreasonable restriction! And may be that's we never read anything asking for that !! :-) Sent via Deja.com http://www.deja.com/