computer science: environments

All material and examples comes from UC Berkeley. Synthesis & inaccuracy is fault of my own, not that of UC Berkeley’s EECS Department. Note that I have not formally taken a CS class, rather do self synthesis. These posts are more so for me to explain it out in a way that I have come to understand and can referrence to later on rather than trying to make it a tutorial.

Computer science programs operate in different series of interrelated environments, which is a mapping from names to values. Global is the encompassing environment frame. Global is often referred to as Parent as well. Subexpressions are evaluated in expressions within its environment. Once evaluated, calls to user-defined functions must evaluate the expressions and statements from the definition of those functions.

If you had code that read:

from operator import mul

def square(x):

return mul(x,x)

x = – 2

Your global would be: mul, square, x

Your expression evaluation would be: square(mul(x,x))

Replace x with -s, so square(mul(-2,-2))

square(-2 * -2)

square(4)

16

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s