This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug with letrec???



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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]