How does an interpreter switch scope?

Posted by Dox on Stack Overflow See other posts from Stack Overflow or by Dox
Published on 2010-05-25T14:43:37Z Indexed on 2010/05/27 6:11 UTC
Read the original article Hit count: 226

I'm asking this because I'm relatively new to interpreter development and I wanted to know some basic concepts before reinventing the wheel.

I thought of the values of all variables stored in an array which makes the current scope, upon entering a function the array is swapped and the original array put on some sort of stack. When leaving the function the top element of the "scope stack" is popped of and used again.

  • Is this basically right?
  • Isn't swapping arrays (which means moving around a lot of data) not very slow and therefore not used by modern interpreters?

© Stack Overflow or respective owner

Related posts about interpreter

Related posts about conceptual