Statistics 540: Keeping code separate from data
Statistics 540: Code separate from data
Announcement
HW issues?
lecture
code ---------------------------------------------------------------------- data
get the picture?
In the beginning:
code on heavy trays
data in lights and tubes
life was good, but backs were sore
The fall from grace--the loadable program
makes data look just like code
consider the following program:
loop: i = i + 1
total = total + a[i]
goto loop
it works, but why? It is self modifying code
i stored here
loop: i = i + 1
total = total + a[i]
goto loop
when i overflows the i = i + 1 command polymorfs into a "goto" which jumps to the value of the instruction total=total+a[i]. Like wow!
Fast forward: modern equivalent is a global variable
a = sort(b)
increasing or decreasing?
check a global maybe?
yikes!
Too ugly to even consider? Look at most operating systems code
Solutions 1: outlaw it
functional programming
some mroe pure than others
remimber: lisp was the orginal functional programming language and was loved since you could write programs that wrote programs!
so it takes some careful control
solution 2: ignore it
leads to microsoft(r) viruses
a word(r) file shouldn't be able to be a program!
solution 3: control it
object orented programming
read chapters 10 and 11
Last modified: Tue Nov 6 08:52:11 2001