chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] Another bug from the net


From: felix winkelmann
Subject: Re: [Chicken-hackers] Another bug from the net
Date: Thu, 23 Jul 2009 17:55:54 +0200

On Tue, Jul 21, 2009 at 9:23 AM, Thomas Bushnell BSG<address@hidden> wrote:
> Chicken gets this wrong:
>
> (let ((cont #f))
>   (letrec ((x (call-with-current-continuation (lambda (c) (set! cont c) 0)))
>            (y (call-with-current-continuation (lambda (c) (set! cont c) 0))))
>     (if cont
>         (let ((c cont))
>           (set! cont #f)
>           (set! x 1)
>           (set! y 1)
>           (c 0))
>         (+ x y))))
>
> Should be 0, but I get 1 in Chicken 3.4.
>

Quite true. This is a known incompatibility and documented as such.
The cases where this matters are usually highly contrived, but the
real reason is that the compiler optimizes local bindings matching certain
patterns. The correct expansion of letrec (which is a macro in chicken)
would break many optimizations of local loops (like named let).


cheers,
felix




reply via email to

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