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.



_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to