chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] letrec expansion


From: Kon Lovett
Subject: Re: [Chicken-users] letrec expansion
Date: Mon, 27 Nov 2006 18:06:31 -0800

On Nov 27, 2006, at 12:23 AM, felix winkelmann wrote:

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.

Maybe a manual statement about deviation from the std? & definition of letrec* perhaps?

You never know the fancy control structures people can come up with given macros & call/cc.



cheers,
felix


--
http://galinha.ucpel.tche.br:8081/blog/blog.ssp


_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]