[plt-scheme] Stylistic (I hope!) question regarding driver loop
On Jan 21, 2006, at 12:46 PM, Jens Axel Søgaard wrote:
> Robby Findler wrote:
>> The body of a letrec is in tail-position wrt to the letrec, so you're
>> set on that score.
>> (FWIW, You can test this out yourself. This program:
>> (define (f x) (letrec ([x x]) (f 1)))
>> (f 1)
>> doesn't accumulate memory, but this one (for example):
>> (define (f x) (letrec ([x (f 1)]) x))
>> (f 1)
>> does. Watch out in the second case -- it allocates memory pretty
>> quickly and gets hard to break pretty quickly too.)
>
> Greg, try using syntax-check on this program in DrScheme:
>
> (define (f x) (letrec ([x x]) (f 1)))
> (f 1)
>
> (define (g x) (letrec ([x (g 1)]) x))
> (g 1)
>
> Then notice the purple arrow, when you
> move the arrow over f.
>
> Then try the same with g.
>
> --
So...you're saying my code is bad because it invokes a function bound
by a letrec in the body of the letrec (like the x in g)?
===
Gregory Woodhouse
gregory.woodhouse at sbcglobal.net
"Nothing is as powerful than an idea
whose time has come."
-- Victor Hugo