Conversation

Anything that crosses an SM_READ macro (the blocking call) is stored in a C struct. The rest goes on the C stack. This is ANF with constants bound to variables as well, to make implementation simpler. C compiler can take care of optimizing those away.
1
Started adding support for CSP rendezvous (csp.h in uc_tools, written in hard-to-use C macros). Added support for zero-copy mode. Eventually this needs to be fast (for the app: 137k int/sec on 72MHz CM3). Might need to specialize the scheduler further.
1
BTW doing this in Lua isn't all that bad. Of course refactoring is hard, but doable at this 1kloc complexity level. However manual let-insertion is annoying. Older Haskell code used a state-continuation monad for that, which is really convenient. Almost magic.
2
End of winter break. Experiment succeeded. Anything more complex needs better abstraction. Feeling a Racket itch coming up...
1
Going to have to specialize the CSP scheduler as well to make this fast. A bit more than a weekend project, but hey I'm learning things.
3
The big lesson is: turn more things into pure functions. It makes partial evaluation trivial. All the work is then moved to purifying library code (in this case the scheduler). E.g. wrap an if n==1 to expose a pure trivial base case to the compiler (while n>1 might be non-trival)