<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 13, 2012, at 11:52 PM, Joe Gilray wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>This function works, but is not "recallable" (is there a better word?). In other words I cannot do the following:</div><div><br></div><div><div style="">(define f1 fib)</div><div style="">(define f2 fib)</div>
<div style="">(f1) (f1) (f2) ...</div><div style=""><br></div><div style="">and have f1 and f2 be separate fibonacci lists.</div></div></blockquote><div><br></div>This is the impulse motivating the historical shift from imperative to object-oriented programming. Whenever you have one or more functions that share mutable state, ask yourself whether one might ever conceivably want more than one instance of that state. Look at your favorite 40-year-old Fortran, BASIC, or Pascal program: odds are that a bunch of different procedures all operate on the same global data. If, for some reason, you needed two instances of all of this, you'd need to duplicate all the procedures and the global variables, which is a Royal Pain. One solution is to have each procedure take the relevant data as parameters (by reference, so they can be mutated), and that works as long as there aren't too many different chunks. I recall writing, as an undergraduate, an OS simulation in which every function took about fifteen parameters, because the teacher had decreed "no global variables". In retrospect, I should have packaged them up into a record/struct, which would not only make the code cleaner and less error-prone but also make it easy to simulate multiple instances of the OS.</div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>Stephen Bloch</div><div><a href="mailto:sbloch@adelphi.edu">sbloch@adelphi.edu</a></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></body></html>