diff options
| author | LLLL Colonq <llll@colonq> | 2026-07-22 00:07:01 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-07-22 00:07:01 -0400 |
| commit | d70a6e5310607a25aabde85d0aa18948704f8f6a (patch) | |
| tree | 0866c493cf75f15cab3b1bec64db1558cfc95fa9 | |
| parent | f10714830fd8a65129d261df3436b885cee871cd (diff) | |
pit: TODO update
| -rw-r--r-- | pit/whereweleftoff.org | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pit/whereweleftoff.org b/pit/whereweleftoff.org index 3b89918..c7a5ccb 100644 --- a/pit/whereweleftoff.org +++ b/pit/whereweleftoff.org @@ -6,3 +6,46 @@ - we can probably make pit_expand_macros operate in place - if we want to be really smart, cool, happy, rich: let's just make stuff translate to a little VM before it evaluates, and let's store VM programs as functions instead of sexps + +* little vm thing +let's have a "program" (representation of one function) be a cons-list of instructions +during execution, we maintain a stack of programs. +calling a lisp function entails pushing a new "frame" to this stack +we iterate over the frame by cdring as usual and we pop the frame when we reach the end + +#+begin_src pit +(defun! add2 (x y) (+ x y 2)) +#+end_src + +#+begin_src pit +[ + (literal x) + (get) + (literal y) + (get) + (literal 2) + (literal +) + (fget) + (apply 3) +] +#+end_src + +#+begin_src pit +(defun! foo (x) (* (add2 x x) 4)) +#+end_src + +#+begin_src pit +[ + (literal x) + (get) + (literal x) + (get) + (literal add2) + (fget) + (apply 2) ;; evaluating this pushes a new frame with the code for add2. next "tick" of evaluator continues in that code. once it returns, result is on the stack (for free) + (literal 4) + (literal *) + (fget) + (apply 2) +] +#+end_src |
