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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7728b533f7ab5fb6 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!w1g2000prk.googlegroups.com!not-for-mail From: Marco Newsgroups: comp.lang.ada Subject: Re: Avoiding side effects Date: Mon, 13 Oct 2008 06:21:00 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 68.63.182.214 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1223904060 22992 127.0.0.1 (13 Oct 2008 13:21:00 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 13 Oct 2008 13:21:00 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w1g2000prk.googlegroups.com; posting-host=68.63.182.214; posting-account=WITAxQkAAAAHjnLda9Lofpqp8mERTWL4 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2353 Date: 2008-10-13T06:21:00-07:00 List-Id: On Oct 13, 5:27 am, Anders Wirzenius wrote: > "(see below)" writes: > > On 08/10/2008 06:16, in article u1vyrbra1....@no.email.thanks.invalid, > > "Anders Wirzenius" wrote: > > > > "(see below)" writes: > > > >> On 07/10/2008 15:47, in article uprmc4g3i....@no.email.thanks.invalid, > > >> "Anders Wirzenius" wrote: > > > >>> "(see below)" writes: > > > >>>> On 07/10/2008 12:08, in article wvbrfxn8hdc7....@sun.com, "Ole-Hjalmar > > >>>> Kristensen" wrote: > > > >>>>> Yes, I think any program which use a read/write interface to a file > > >>>>> will havesideeffects in that sense. The only way I can think of for > > >>>>> avoiding this would be to mmap the whole file, then it will appear as > > >>>>> an array of bytes. > > > >>>> Why would stepping through an array not be thought a "side"effect? > > > >>> A function that returns the row of that array and only that > > >>> would perhaps be a function withoutsideeffects. The information > > >>> in that row can be fetched when needed. > > > >> A function that always returns the same row of an array would be of little > > >> use, I should think. > > > > I have a feeling that the function can be programmed so that it returns > > > different row (numbers, or pointers in that array) depending on > > > the content of the rows in that array ;-) > > > > function Row_Number (Row_Number_In_Other_Array : in > > > Row_Number_Type) return Row_Number_Type is > > > -- Return a row number one higher than the row number of the row > > > -- identical to the row in the other array. > > > I think this beautifully illustrates the silliness that slavish adherence to > > dogma inevitably produces, in programming as in finance and politics. > > The thread I started was about how to avoidsideeffects. From > the answers I have been reading that for a case where you compare > the content of two files, it is rather hard to do it with > functions without havingsideeffects. > > Is the dogm you refer to something like "functions withoutside > effects". > > I am not a professional programmer any more and I just > wanted to learn something aboutsideeffects. What is silly in > that? nothing, but I agree don't get carried away with the concept, Functional Programming is kind of an extreme backlash to the Object Oriented push of the late 80's and 90's, in the end, both are useful but is important to keep as many functions "pure" as possible because these tend to be easier to verify and are more reusable in other contexts. http://en.wikipedia.org/wiki/Pure_function At work, we are trending away from the pure OO stuff to a mixed approach.