Xref: utzoo comp.lang.c:11521 comp.arch:5721 Path: utzoo!attcan!uunet!lll-winken!lll-lcc!lll-tis!ames!zodiac!joyce!sri-unix!garth!smryan From: smryan@garth.UUCP (Steven Ryan) Newsgroups: comp.lang.c,comp.arch Subject: Re: Self-modifying code Message-ID: <1081@garth.UUCP> Date: 26 Jul 88 18:44:45 GMT References: <5262@june.cs.washington.edu> <260@thor.wright.EDU> <759@cernvax.UUCP> <472@m3.mfci.UUCP> <60782@sun.uucp> <473@m3.mfci.UUCP> <1988Jul23.221743.22169@utzoo.uucp> <477@m3.mfci.UUCP> <1075@garth.UUCP> Reply-To: smryan@garth.UUCP (Steven Ryan) Organization: INTERGRAPH (APD) -- Palo Alto, CA Lines: 25 In article <1075@garth.UUCP> smryan@garth.UUCP (Steven Ryan) writes: >>If the machine allows a change to one variable (an array, say) to >>affect some other unrelated variable, then it is not conforming to >>the intent of my program. In fact, it is not conforming to anything >>useful at all, since nobody would argue that it is useful programming >>practice to ever do such a thing on purpose (I hope?). > >This particular example is done all the time in handling recursive data >structures. What do I mean by that? [I do not know how to reply by private mail--student driver.] A simple example is reversing a singly linked list and, just to make it interesting, inserting the list ordinal: p := nil; q := first_element; n := 1; while q isnt nil do r := q.link; -- r and q.link are variables pointing at the location. q.link := p; -- p and q.link are now pointing at the same location. p := q; -- now p and q. p.ordinal := n; -- as a sideeffect, also modifies q.ordinal. q := r; -- now r and q. n +:= 1 od