chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] crazy behaviour in csi!


From: Sunnan
Subject: Re: [Chicken-users] crazy behaviour in csi!
Date: Tue, 06 Dec 2005 01:49:53 +0100

On Mon, 2005-12-05 at 23:49 +0000, Thomas Chust wrote:
> On Mon, 5 Dec 2005, Sunnan wrote:
> 
> > [...]
> > I hadn't looked at srfi-31 before. I thought I knew most of the srfis.
> > This one was pretty disappointing.
> > [...]
> 
> Hmm, most of the time I don't need this type of thing, but if I want to 
> pass an anonymous callback that is recursive, the rec form comes in quite 
> handy. I find writing
>    (letrec ((loop
>               (lambda (p)
>                 (if (pred? p) (foo p) (loop (bar p))))))
>      loop)
> much more awkward than
>    (rec (loop p) (if (pred? p) (foo p) (loop (bar p)))

How about
(lambda (p) (let loop ((p p)) (if (pred? p) (foo p) (loop (bar p)))))

Yeah, I know, it's slightly more awkward (three more symbols) and if you
use it all the time, using rec might be a win, but if you do something
all the time there's usually an even more winning way.

Thanks for the example (anon callbacks), though.





reply via email to

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