[plt-scheme] Semantics of let

From: John Clements (clements at brinckerhoff.org)
Date: Thu Feb 23 21:42:42 EST 2006

On Feb 23, 2006, at 3:55 PM, Greg Woodhouse wrote:

> --- Jim Blandy <jimb at red-bean.com> wrote:
>
>>
>> Semantics: A lambda expression evaluates to a procedure. The
>> environment in effect when the lambda expression was evaluated is
>> remembered as part of the procedure. When the procedure is later
>> called with some actual arguments, the environment in which the
>> lambda
>> expression was evaluated will be extended by binding the variables in
>> the formal argument list to fresh locations, the corresponding actual
>> argument values will be stored in those locations, and the
>> expressions
>> in the body of the lambda expression will be evaluated sequentially
>> in
>> the extended environment.
>>
>>
>> So that's kind of a recipe for how to implement it as well.
>>
>
> Thanks. I'll try associating a hash table with each lambda expression
> in the environment. (There's probably something wrong with THAT
> idea,too, but well, we'll see.)

You might be interested in checking out a programming languages  
textbook.  In fact, I would recommend a look at Shriram  
Krishanmurthi's Programming Languages: Applications & Interpretation,  
which happens to be available on the web at

http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/

It covers the issues involved in lexical vs. dynamic scoping quite  
clearly.

John



Posted on the users mailing list.