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: Thomas Chust
Subject: Re: [Chicken-hackers] serious bug ? in units and set!
Date: Tue, 22 Sep 2009 12:10:46 +0200

2009/9/22 Thomas Bushnell BSG <address@hidden>:
> On Tue, 2009-09-22 at 10:30 +0200, Thomas Chust wrote:
>> [...]
>> (set! foo 'whiz) at the top level with no previously defined variable
>> called foo *does* establish a binding for foo.
>
> Of course.  But test2.scm has no set! at top level:
> [...]

Hello,

right, I'm sorry, I misread the original code and thought the set! was
outside the function definition :-( Now I find the behaviour somewhat
strange as well.

For what it's worth, CHICKEN 4.2.0 shows the same behaviour and even
stranger things happen when I change the code slightly:

  $ cat test2.scm
  (declare (unit test2) (export blah))
  (define (blah) (format #t "foo: ~s~%" foo) (set! foo 'whiz))
  $ cat main.scm
  (declare (uses test2) (export foo))
  (define foo #t)
  (blah)
  $ csc -o foo test2.scm main.scm
  foo: whiz
  $ ./foo
  $

Why on earth is the content of the procedure definition evaluated at
compile time and not at runtime here? Is maybe some compiler magic to
blame that tries to "optimize" expressions into constants even though
they have side effects?

Ciao,
Thomas


-- 
All these theories, diverse as they are, have two things in common: They
explain the observed facts, and they are completely and utterly wrong.
                               -- Terry Pratchett, "The Light Fantastic"




reply via email to

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