I realized this evening that the problem I’m facing in my Scheme->Forth

compiler is one of lexical scope. Forth doesn’t have a notion of scope at the word (procedure) level.

UIL (Universal Intermediate Language) does.

Either I need to

  1. CPS UIL (not so tragic, really)
  2. Jump out of the compiler to Forth at a lower level (closer to assembly) when scoping issues have been resolved.

The former is particularly Schemely, and shouldn’t be too hard at this point (UIL is fairly simple overall).

There are probably other solutions I can implement as well, although they would probably (effectively) result in #2.

Bailing later would be guaranteed to work, especially if I dumped into Forth after register allocation.

This would, effectively, guarantee success.

I’ll have to reread the chapters on CPS in Essentials of Programming Languages before going to bed, and

invoke my continuation on this tomorrow morning…

One Response to “Scope… always scope…”

  1. Matt says:

    Of course, I didn’t mean (after further thought) that I’d want to CPS UIL… that adds too much overhead. But applying the transform much earlier achieves the same effect.

    I think I’ll read Amr’s dissertation–it’s on CPS and direct styles in compilation, so it should be applicable and interesting.