Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!boulder!ccncsu!bizet.CS.ColoState.Edu!rro From: rro@bizet.CS.ColoState.Edu (Rod Oldehoeft) Newsgroups: comp.lang.misc Subject: Re: side effects Message-ID: <2270@ccncsu.ColoState.EDU> Date: 27 Jul 89 17:28:11 GMT References: Sender: news@ccncsu.ColoState.EDU Reply-To: rro@bizet.CS.ColoState.Edu.UUCP (Rod Oldehoeft) Organization: /etc/organization Lines: 39 In article gb17+@andrew.cmu.edu (George Thomas Baggott) writes: >In a truly functional language (i.e. no side effects at all), a function >for altering a large data structure (adding an entry to a dictionary, >for example) would be written as: > > dictionary_add(dictionary, entry) returns dictionary; > /* return a copy of dictionary with entry added to it */ > >This is very costly, however. If side effects were allowed, you could >do it at a much smaller cost: > > dictionary_add(dictionary, entry); > /* add entry to dictionary */ > >Is there some way to have a language with no side effects, yet still be >able to solve this class of problems in a practical way? If not what is >the minimum amount of comprimise that must be made? > > >George Single assignment semantics requires that an aggregate value be copied if one wishes to modify an element of the value. However, an implementatiion may observe the last use of a value and update it in place. We have done this for SISAL with good results, although there are still instances where recognition does not take place. A Postscript version of David Cann's Ph.D. dissertation with all the gory detail on this subject is available via anonymous ftp from handel.CS.ColoState.EDU (129.82.102.16). See file TR.89-108.ps in the directory ~ftp/pub/SISAL. Rod Oldehoeft Email: rro@CS.ColoState.EDU Computer Science Department Voice: 303/491-5792 Colorado State University Fax: 303/491-2293 Fort Collins, CO 80523