[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] letrec expansion
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] letrec expansion |
Date: |
Mon, 27 Nov 2006 09:23:56 +0100 |
On 11/26/06, Dan Muresan <address@hidden> wrote:
Hi,
I've noticed that letrec seems to have a problematic expansion. I'm
not sure if this has been discussed before (I couldn't find any
matches):
csi> (macroexpand '(letrec ((x 1)) x))
(let ((g1312 (##core#undefined))) (begin (##core#set! g1312 (quote 1)) g1312))
This definition doesn't use temporaries -- as, for example, in the
standard R5RS syntax-rules definition of letrec,
Yeup, you're right. Chicken's letrec is essentially what R6RS calls letrec*.
Without using temporaries, some call/cc + letrec combinations don't work:
(letrec ((x (call/cc list)) (y (call/cc list)))
(if (procedure? x) (x (pair? y)))
(if (procedure? y) (y (pair? x)))
(let ((xk (car x)) (yk (car y)))
(and (call/cc xk) (call/cc yk) (call/cc xk))))
Fully correct. The full standard-compliant expansion of letrec
would be slower, so I keep it the way it is.
I would be surprised to find a real-world example where this makes
a difference.
cheers,
felix
--
http://galinha.ucpel.tche.br:8081/blog/blog.ssp