V를 위한 Lisp, 그리고 진짜로 공짜인 꼬리 호출
명시적인 CEK 머신 위의 작은 Lisp 방언입니다. 꼬리 위치의 호출은 새 프레임을 쌓는 대신 자기 프레임을 재사용하므로, 반복은 반복입니다. 죽을 때까지 부풀어 오르는 스택이 아닙니다.
이 절은 아직 사용자의 언어로 번역되지 않아 영어로 표시됩니다. 번역은 환영합니다.
A taste
(define (fib n)
(if (< n 2)
n
(+ (fib (- n 1))
(fib (- n 2)))))
(fib 20) ;=> 6765
이 절은 아직 사용자의 언어로 번역되지 않아 영어로 표시됩니다. 번역은 환영합니다.
무엇인가
Real tail calls
A quarter of a million iterations end with an empty continuation stack. Mutual recursion tail-calls too, which is the part most trampolines skip.
An explicit machine
Evaluation is a data structure you can inspect, not a recursive function you have to trust. Every step is counted, and every limit is a field you can set.
Embeddable by shape
The machine is a library with no global state. print output is collected into a field, so a host can capture it rather than fight it.
이 절은 아직 사용자의 언어로 번역되지 않아 영어로 표시됩니다. 번역은 환영합니다.
Where it stands
Working: the reader, closures, arithmetic, branching, loop, dotimes, letrec, cond, case, and proper tail calls including mutual recursion.
Not yet: let*, rest parameters, callable keywords, modules, and macros. Each one is named in the repository rather than quietly missing.