Idea dynamic vs. static 

Forum: Com Sci 221, U Chicago, Autumn 2001, Old Classwork
Re: News Assignment #7 due Monday, 19 November (Mike O'Donnell)
Re: Question dynamic scope? and tree representation? (Terry (Sotiria) Lampoudi)
Date: 2001, Nov 18
From: Roni Choudhury roni

First of all, regarding exercise 1, I'm having a hard time figuring out how static and dynamic scope are supposed to change the behavior of the supplied function. Specifically, I don't get it because it seems to me that evaluation order is all that should matter. So when I see a lambda I evaluate the second argument (the function), which in all of the lambdas I see is not actually a function of the formal parameter, so I pretty much ignore the formal parameter. So if there is no global scope and in each lambda the formal parameters are not used, then I don't quite see how dynamic vs lexical scope is going to matter.

The idea here is that z gets bound twice during the execution of this program. The first time (the "legitimate" time) z gets bound to 'y, and the second time (deep inside nested lambdas) it gets 'x. We want the function f to return the original z, because f is bound in a scope that does not include the second binding of z. As far as I can tell, it works something like this:

1. z gets 'y
2. f gets (lambda () z)
3. z gets 'x
4. f runs

Here, under static scoping rules, when you execute f, it should return z as it was when f was bound. Since z changes away from 'y after f was bound, we want f to return 'y.

My problem is, I don't know what it means to give a function an environment, unless we mean a static environment that is defined at the time that the function is defined. Hmm...that might actually work...what do you guys think?

roni


Messages

1. Agree I think that's it... by Matthew Stover, 2001, Nov 18
2. Feedback order of building lamda and subbing reals for fmls (Terry (Sotiria) Lampoudi), 2001, Nov 18
1. Idea My Evaluator by Mamun Tanveer, 2001, Nov 18
2. Feedback It's the order of substitution vs. application of the function by Mike O'Donnell, 2001, Nov 19
3. Agree Right, but remember the recursion stack by Mike O'Donnell, 2001, Nov 19

to: "dynamic vs. static"