chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] Re: Numbers egg interaction with other compiled code.


From: Tony Sidaway
Subject: [Chicken-hackers] Re: Numbers egg interaction with other compiled code.
Date: Thu, 22 Oct 2009 00:01:47 +0100

To illustrate how I think things are supposed to work, here is a
simple example I just typed at the "csi" prompt:

#;1> (define (f) 10)
#;2> (define (a) (f))
#;3> (a)
10
#;4> (define (f) 12)
#;5> (a)
12

So procedure a depends on procedure f.  But f is just a variable whose
value happens to be associated with a certain lambda expression that
yields the value 10.  If I then change the value of f to a lambda
expression that yields the value 12, this changes the behavior of a,
by changing the code it executes when it hands control to whatever
procedure is associated with the symbol f.

So if we redefine negative? to do something wonderful with bignums,
then everywhere in the program that has access to the binding
"negative?" should see the change.  No?

On 10/21/09, Tony Sidaway <address@hidden> wrote:
> Here's a bit of code that shows my problem.  This is with stock
> chicken 4.1.0 and the latest release of numbers.egg
>
> (module fred (export f)(import chicken scheme)
> (declare (not usual-integrations))
> (define (f n) (negative? n)))
>
> Compile this, load it into csi and import.
>
>> (f #b101010)
> ===> #f
>
>> (f #b1010101010101010101010101010101010)
> "Illegal number syntax" error because it's too big.
>
> Okay, let's try bignums.
>
>> (use numbers)
> Error: (negative?) bad argument type: 11453246122
>
> It doesn't seem to be expecting a bignum.
>
> On the other hand:
>
>> (negative? #b1010101010101010101010101010101010)
> ===> #f
>
> What's going on?  I thought (not usual-integrations) would make sure
> the redefined version of "negative?" would be picked up by code inside
> module fred, but evidently this isn't the case, at least at the
> default level of code optimization.
>
> Is this a bug or do I just misunderstand how Scheme is supposed to work?
>




reply via email to

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