HuoLanguage / huo

interpreted language written in C
MIT License
212 stars 21 forks source link

Devise a better system for storing variables in scope #38

Open incrediblesound opened 8 years ago

TheLoneWolfling commented 8 years ago

So, a couple of thoughts:

  1. Tangential: the current approach of "C call stack mirrors the huo call stack", although it works for now, can cause problems. I personally prefer non-recursive intrepreters. This would require a lot of rewriting.
  2. How do we want to handle scope? Straight lexical scoping? Other?
  3. Do we want explicit nonlocal / global statements, similar to Python?

Effectively, figure out the API and then figure out how to get the language to implement the API.

incrediblesound commented 8 years ago
  1. I like the idea of the non-recursive interpreter. I think I'll play with that idea because it's clear to me now that the current recursive approach is too confusing. I will probably make a simple prototype in JS to understand the stack based approach before I attempt it here, but this is exactly the kind of problem I enjoy working on.
  2. Hmmm, I'm not sure about the implementation details of lexical scoping vs. dynamic scoping. I will do more research.
  3. I think global statements are generally useful, but it might be interesting to leave them out!