Implementing dynamic scope when using CPS as intermediate language
- by asandroq
I am currently studying the implementation of programming languages and became interested in using Continuation-Passing Style as the intermediate language of the compiler. I also want to implement limited dynamic scope (for exception-handling or Scheme parameter objects) but I cannot find the relevant literature. I think it can be done with a separate environment passed as a variable to every closure, but this solution seems ugly to me.
Could anyone point me to the relevant literature, or give me an idea of how this can be done?