Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Unlocked Android phone



Hi,

On Tue, Dec 9, 2008 at 5:29 PM, Curt Sampson <cjs@example.com> wrote:
> I would guess, actually, that you could use most any language that can
> compile to a JVM. Admittedly, compared to what's available in C or
> similar for Linux, that's still a very limited set of options. Wikipedia
> mentions only Ruby, Groovy, JavaScript, Python, Common Lisp, Scala,
> Forth, and Clojure.
>
> Still, the JVM can't do efficient tail recursion, and I don't think that
> any of the above have compilers will change a tail call into a loop....

It's true that the JVM doesn't support tail recursion natively.
Clojure works around this with special syntax[1] and a "trampoline for
mutual recursion"[2][3]:

"""
I've added trampoline to ease the conversion/creation of mutually
recursive algorithms in Clojure.

Trampolines are a well known technique for implementing TCO - instead
of actually making a call in the tail, a function returns the function
to be called, and a controlling loop calls it, thus allowing chained
execution without stack growth.
"""

Mike


[1] Search for the text "recur exprs" at http://clojure.org/special_forms
[2] http://groups.google.com/group/clojure/browse_frm/thread/6257cbc4454bcb85/7d5fd827cd549080#7d5fd827cd549080
[3] I'm still new to Clojure and functional programming, so it's
possible that the recur syntax and the trampoline are one and the same
thing, and I just don't know it.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links