From 5d6337a3cdbc5b9642fbbe8a0346b0c59808a554 Mon Sep 17 00:00:00 2001 From: Juha Jeronen Date: Tue, 5 Nov 2019 02:02:48 +0200 Subject: [PATCH] Add note on Clojure's trampoline --- doc/features.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/features.md b/doc/features.md index d5c487b4..aa5be9d4 100644 --- a/doc/features.md +++ b/doc/features.md @@ -1825,6 +1825,14 @@ def baz(result): foo() # start trampoline ``` +#### Similar features in Lisps - `trampoline` in Clojure + +Clojure has [`(trampoline ...)`](https://clojuredocs.org/clojure.core/trampoline), which works almost exactly like our `trampolined`. + +The `return jump(...)` solution is essentially the same there (the syntax is `#(...)`), but in Clojure, the trampoline must be explicitly enabled at the call site, instead of baking it into the function definition, as our decorator does. + +Clojure's trampoline system is thus more explicit and simple than ours (the trampoline doesn't need to detect and strip the tail-call target's trampoline, if it has one - because with Clojure's solution, it never does), at some cost to convenience at each use site. We have chosen to emphasize use-site convenience. + ### ``looped``, ``looped_over``: loops in FP style (with TCO)