RFC on my letrec macro

12 views
Skip to first unread message

Michał Marczyk

unread,
Jul 22, 2010, 10:38:50 PM7/22/10
to clo...@googlegroups.com
Hi All,

I've written a letrec macro with the goal of hopefully tying the knot
[1] in Clojure etc. Some examples of what it can do are included in
the Gist (including -- as of now -- two not immediately rewritable in
terms of letfn). So far I haven't caught any bugs, but hey, it's about
an hour old and the knot is still untied... Any comments / suggestions
/ remarks on this being crazy?

http://gist.github.com/486880

Sincerely,
Michał

[1] http://www.haskell.org/haskellwiki/Tying_the_Knot

George Jahad

unread,
Jul 23, 2010, 12:50:03 AM7/23/10
to Clojure
i like it a lot! what do you think of adding trampoline to it like
so:

http://gist.github.com/487019

Michał Marczyk

unread,
Jul 23, 2010, 1:50:49 AM7/23/10
to clo...@googlegroups.com
On 23 July 2010 06:50, George Jahad <clo...@blackbirdsystems.net> wrote:
> i like it a lot!   what do you think of adding trampoline to it like
> so:
>
> http://gist.github.com/487019

Thanks!

Trampoline in letrec automatically breaks all cases where the value
being bound to the local is not a function, so it would interfere with
what I'm trying to do. Having said that, it seems to me that it's a
very cool idea for a custom letfn variant permitting mutual recursion
of unbounded depth. I'll investigate this further.

All the best,
Michał

George Jahad

unread,
Jul 23, 2010, 2:11:08 AM7/23/10
to Clojure
sorry, wrong gist. here's one that tests for a function and only
calls trampoline on it. all three of your test cases work for it.

http://gist.github.com/487019

g

On Jul 22, 10:50 pm, Michał Marczyk <michal.marc...@gmail.com> wrote:

George Jahad

unread,
Jul 23, 2010, 10:19:53 AM7/23/10
to Clojure
Just realized there are many types of recursive functions for which
trampoline can't be used in this way. It's an interesting problem
though. I'm going to think some more about it.


On Jul 22, 11:11 pm, George Jahad <cloj...@blackbirdsystems.net>
wrote:
Reply all
Reply to author
Forward
0 new messages