chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] serious bug ? in units and set!


From: Jim Ursetto
Subject: Re: [Chicken-hackers] serious bug ? in units and set!
Date: Tue, 22 Sep 2009 00:08:33 -0500

An actual example of what you're trying to achieve would probably
help, because the example you gave is rather convoluted.

But it short it doesn't "work" (for certain values of work) because
you exported "blah" in test2.scm, implying -- as a consequence -- that
every other binding is hidden, including "foo".  So the compiler does
an optimization where "foo" is not looked up globally but locally in
test2.  Then, as a further optimization since you didn't give foo any
value to start with, the compiler just chooses 'whiz for the default,
moving the set! to toplevel initialization time, which is actually
pretty neat.

In short, change (export blah) to (export blah foo) in test2.scm and
it will behave as you desire... I guess. :)

On Mon, Sep 21, 2009 at 8:31 PM, Thomas Bushnell BSG <address@hidden> wrote:
> test2.scm contains:
>  (declare (unit test2) (export blah))
>  (define (blah) (display (format "foo: ~s\n" foo)) (set! foo 'whiz))
>
> main.scm contains:
>  (declare (uses test2) (export foo))
>  (define foo #t)
>  (blah)
>
> Compile with csc -o foo test2.scm main.scm and run it.  And the output
> is:
>
> foo: whiz
>
> On Chicken Scheme 3.4.0 in current Debian unstable.
>
> If all these definitions are put in one file, then the output is
> foo: #t
> as expected.
>
>
>
>
> _______________________________________________
> Chicken-hackers mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/chicken-hackers
>




reply via email to

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