chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Internal defines broken when compiled?


From: Felix
Subject: Re: [Chicken-users] Internal defines broken when compiled?
Date: Mon, 07 Feb 2011 11:15:12 +0100 (CET)

From: Eric Jiang <address@hidden>
Subject: [Chicken-users] Internal defines broken when compiled?
Date: Fri, 4 Feb 2011 11:47:18 -0500

> Hi all,
> I wrote a procedure with several internal defines, and am running into
> problems with the compiled program.  Running the compiled program
> gives an "unbound variable" error for a Chicken-generated variable.
> 
> The following snippet reproduces the error:
> 
>     (define (x)
>       (define (foo) (length bar))
>       (define bar `(1 2 3 ,foo))
>       (foo))
> 
>     (x) ;; should give 4
> 
> However, this example works when interpreted in csi and petite.  I
> searched the manual for some indication of whether this behavior in
> csc is documented, but did not turn up anything.
> 
 
This is invalid Scheme code: the internal defines are converted
into a `letrec' form and in a `letrec', the right-hand-side expressions 
may not refer directly to the bound variables:

  (letrec ((foo ...)
           (bar foo))      ; illegal
    ...)

  (letrec ((foo ...)
           (bar (lambda ... foo ...)))  ; ok
    ...)


cheers,
felix



reply via email to

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