홈 / 기능
기능
머신이 오늘 하는 일과, 무엇을 위해 만들어졌는지.
이 절은 아직 사용자의 언어로 번역되지 않아 영어로 표시됩니다. 번역은 환영합니다.
무엇을 하는가
Proper tail calls
A call in tail position reuses the current continuation frame instead of pushing one. Self-recursion and mutual recursion both loop in constant space.
An explicit CEK machine
Control, environment, and value are separate machine fields. Recursion in the evaluator is a tail call, so the V stack cannot overflow on a vlip loop.
Only #f is false
As in R5RS and Clojure: 0, the empty string, nil, and () are all true. Ruby and JavaScript say the opposite, which is why newcomers relearn this.
Core and derived forms
A small core that everything else desugars into, so each derived form gets tail calls for free instead of needing its own trampoline.
Bounded evaluation
Step and continuation-depth limits are fields on the machine, not constants, so a host can bound untrusted code.
No global state
One Machine value holds everything. Two can run side by side with no interference, which is what makes embedding and testing possible.
이 절은 아직 사용자의 언어로 번역되지 않아 영어로 표시됩니다. 번역은 환영합니다.
왜 명시적인 머신인가
A tree-walking evaluator written as a recursive function runs out of C stack before it runs out of vlip stack. Every non-tail vlip call becomes another V frame, so the host's limit becomes your limit.
Writing the evaluator as an explicit machine with its own heap stack moves that boundary somewhere you can see. The cost is a step counter and a dispatch loop. The benefit is that the numbers in the table below are measured rather than hoped for.
이 절은 아직 사용자의 언어로 번역되지 않아 영어로 표시됩니다. 번역은 환영합니다.
측정값
| Test | Iterations | Result | Stack at end |
|---|---|---|---|
| self tail call | 250,000 | 250000 | 0 |
| mutual tail call | 20,000 | pong | 0 |
| tail call in cond | 100,000 | 100000 | 0 |
| tail call in let | 50,000 | 50000 | 0 |
| fib, non-tail | 20 | 6765 | 0 |
| loop, summing | 20,000 | 199990000 | 0 |
이 절은 아직 사용자의 언어로 번역되지 않아 영어로 표시됩니다. 번역은 환영합니다.
마지막 열을 보세요
A stack depth of zero at the end is the whole claim. Without real tail calls that column would hold the iteration count instead. Every number here is produced by the test suite that CI runs, so none of them can drift away from the implementation unnoticed.