Jump to content
  • Advertisement
Sign in to follow this  
Mokujin

Scheme

This topic is 4578 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to modify the interpreter so that the free variables are evaluated at the time the procedure is called, not when it is created. Any hints?

Share this post


Link to post
Share on other sites
Advertisement
Could you clarify? Unless I'm misunderstanding you, Scheme does that already. Also, what interpreter?

Share this post


Link to post
Share on other sites
We are "creating" the interpreter, and now it evaluates the free variables when it is created.

Share this post


Link to post
Share on other sites
This is a difficult question when we dont know how your interpreter is written. When I wrote a Scheme interpreter in Scheme last year each closure had its own environment. There was also a global environment. When I went to evaluate a variable I first searched for it in the most local environment and if it wasnt there then in the environment of the next closest scope.

If you're evaluating a variable in a function which is has global scope then you first try to find it in the function's environment. Since the variable is free, it wont be there. So then you search for it in the global environment.

If you still cant find it then you throw your hands up and tell the user "Undefined variable"

Hope that helps

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!