chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] numbers stuff


From: Peter Bex
Subject: Re: [Chicken-hackers] numbers stuff
Date: Sat, 23 May 2015 00:07:57 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, May 18, 2015 at 12:49:09PM +0200, Peter Bex wrote:
> On Mon, May 18, 2015 at 12:39:36PM +0200, address@hidden wrote:
> > Another question: should "C_num_to_long" and "C_num_to_unsigned_long"
> > handle bignums? The same goes for "C_i_foreign_integer..." and
> > friends?
> 
> hm, they probably should.  I suppose I overlooked them.  I though
> only C_num_to_int was used.

I just pushed this, along with some tests, which exposed a few more bugs
which I also fixed:  I had forgotten to update the size calculations for
bignums after switching the representation to the new style where
bignums are strings wrapped inside records.  Also, the handling of
foreign return values of type int64 was incorrect on 32 bits.

Finally, while writing the tests, I noticed that the foreign argument
type stub converter functions only performed range checking for flonums,
but never for fixnums.  This can either be an oversight (assuming that if
it fits a fixnum, it will always fit an integer), or for performance.

If it's an oversight; it's wrong because a) unsigned types should not
allow negative values and b) "int" is smaller than C_word on 64-bit
machines, I think, so a fixnum can be larger than will fit an int.

If you agree, I can add this range checking and uncomment some of the
tests that I added.  I'm unsure about the CHICKEN 4 branch; do we want
to add this extra checking there as well?

Cheers,
Peter

Attachment: signature.asc
Description: Digital signature


reply via email to

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