On Fri, 19 Mar 2004, Ivan Boldyrev wrote:
> Are there (CMUCL-specific) functions for fast fixnum arithmetics? > I don't need bignum arifmethics; for example, > > (fixnum+ most-positive-fixnum 1) > > should retrun -1. You want a bit more than what you can get here. At best, the system can give you the guarantee to produce an unspecified value. At worst, the behaviour is undefined. (A friend of mine is constantly dreaming of implemting a special ANSI-C compliant version of libc that formats your harddisk whenever you do something of which the standard says that it may result in undefined behaviour - for use in education.) > Speed is most important for me now :) Before people start to explain to you that this is not the way how one should approach this issue and how great and glorious the type inference of cmucl is(*) as it can deal so nicely with integer range propagation, my approach to this is to put a few macros into my own spellbook (google for cl-tf-spellbook, the university's webserver is down today, but you may have luck finding it in the Google cache) that expand, say, i+ to (the fixnum (+ (the fixnum arg1) (the fixnum arg2) ...) If you compile this with (declare (optimize (safety 0) (speed 3))), it just gives you what you want. (*) For many applications, it is not. Say you have a number N which you want to use as an array index, plus you want to form some derived quantities from it which also are used as array indices (typically N+1, N-1, 2*N). Besides this, you have no good criterion at compile time to set an arbitrary limit for the size of the array. So, what integer range do you give that beast? -- regards, [EMAIL PROTECTED] (o_ Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\ (lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y) V_/_ (if (= x 0) y (g g (- x 1) (* x y)))) n 1)) (Debian GNU)
