pvdrz / pijama_legacy

A functional programming language
MIT License
47 stars 4 forks source link

Redesign Pijama's IRs #68

Open pvdrz opened 4 years ago

pvdrz commented 4 years ago

In this moment we have two IRs based on the lambda calculus which have been a great way to start because the typing rules are easy and you can express a lot of intricate programs with them without changing its structure.

However, there are some problems with those IRs:

I like to propose we move to more traditional IR based in one of the following:

DarkDrek commented 4 years ago

For me the continuation passing style form is at least conceptional the easiest to understand and at the same time a bit interesting. As for the others the static single assignment form is also easy to understand and the spineless tagless G machine is something I can't comment on but it seems to advanced.

pvdrz commented 4 years ago

I've been checking how Haskell works as we share certain features such as currying with it. So the idea is that there are two IRs

In our case LIR is like MIR but with less syntax. Which makes the lowering easy, but executing LIR is almost as slow as executing MIR. The only advantage is that there are no naming issues because LIR has no names at all.

I think we can try to do some fixes to our MIR but keep it almost untouched. And focus on changing LIR by something that we can execute easily. What do you think?

I haven't found enough info about CPS even though I like the model. If you happen to have any good sources to see how it works in a compiler I'd love to give it a look