[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Internal defines broken when compiled?
From: |
Eric Jiang |
Subject: |
Re: [Chicken-users] Internal defines broken when compiled? |
Date: |
Mon, 7 Feb 2011 14:10:21 -0500 |
I was under the impression that internal defines expanded into
letrec*, since csi runs and gives 4 for the sample (and using 'expand'
was no help). Would it be reasonable, then, to request that csi have
the same behavior and for csc to give a meaningful error when it
detects this? (Or for internal defines to be letrec* a la R6RS?)
Much thanks,
Eric
On Mon, Feb 7, 2011 at 5:15 AM, Felix
<address@hidden> wrote:
> 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
>