Головна / Можливості

Можливості

Що машина робить сьогодні і для чого її створено.

Читати документацію Вихідний код

Цей розділ ще не перекладено вашою мовою, його показано англійською. Переклади вітаються.

Що вона робить

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.

Цей розділ ще не перекладено вашою мовою, його показано англійською. Переклади вітаються.

Виміряно

TestIterationsResultStack at end
self tail call250,0002500000
mutual tail call20,000pong0
tail call in cond100,0001000000
tail call in let50,000500000
fib, non-tail2067650
loop, summing20,0001999900000

Цей розділ ще не перекладено вашою мовою, його показано англійською. Переклади вітаються.

Погляньте на останній стовпець

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.