chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] fixnum-specific math operators patch


From: Will M Farr
Subject: [Chicken-users] fixnum-specific math operators patch
Date: Thu, 31 Aug 2006 19:51:31 -0400

Hello all,

In the spirit of my last post about flonum-specific math operators, attached is a patch which implements the following behavior for Chicken's fxXXX math operators:

In safe mode: all fxXXX operators check that their arguments are really fixnums and throw an error if they are not.
In unsafe mode: all fxXXX operations check no argument types.

In both cases the fxXXX operators do not check for overflow (i.e. you can think of them as operating mod 2^n with n dependent on the system word size). Right now all fxXXX operations are unsafe (in the sense that you can perform them on non-fixnums and get nonsense---but fixnum---results, not in the sense that they crash the system).

This patch would slow down code compiled in safe mode which uses the fxXXX operators because of the extra two checks per operation, but would detect stupid errors such as:

#;1> (fx+ 10 1.0)
230436

in safe mode. In unsafe mode the operation would not change at all. I suspect this is a much more controversial change than my last patch, but if felix and the community think it's OK, I'd be happy to edit the manual to reflect the new behavior.

Will

Attachment: library.patch
Description: Binary data


reply via email to

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