This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Bug with letrec???
- To: Norbert Preining <preining at logic dot at>
- Subject: Re: Bug with letrec???
- From: Lars Arvestad <arve at nada dot kth dot se>
- Date: 20 Mar 2000 13:20:18 +0100
- Cc: guile at sourceware dot cygnus dot com
- References: <20000320092038.A17184@mandala.priv.at>
NP> it seems that letrec is not working correct?! I thought this is the
NP> standard behaviour according to RnRS? What is the difference between
NP> letrec and let in this case?
It works correct. Here is from R5RS:
One restriction on `letrec' is very important: it must be possible
to evaluate each <init> without assigning or referring to the
value of any <variable>. If this restriction is violated, then it
is an error. The restriction is necessary because Scheme passes
arguments by value rather than by name. In the most common uses
of `letrec', all the <init>s are lambda expressions and the
restriction is satisfied automatically.
What you want is let*. Notice that the following works:
(letrec ((a 1) (b 2) (c (lambda ()(+ a b)))) (c))
Cheers,
Lars
--
Lars Arvestad Stockholm Bioinformatics Center
Stockholm University, Karolinska Institute & Royal Institute of Technology