From: Nikodemus Siivola <nikodemus@ra...>  20080804 12:34:51

On Wed, Apr 9, 2008 at 5:49 PM, Martin Rubey <martin.rubey@...> wrote: > I believe I just realised that > > (* x y) > > is *exactly* as fast in sbcl as > > (* (the integer x) (the integer y)) > > i.e., there is no point at all declaring integers, except of course, if for > some reason sbcl can prove that x and y are in fact fixnums. > > Is that correct? > > I guess the same actually holds for > > (+ (the integer x) 1) > > doesn't it? (or is there a faster way to increment a bignum by one?) > > In case the answers to the above are "yes", is that a principal impossibility, > or just because noone implemented something better (in sbcl)? Sorry for the late answer, but... Yes and no. If there isn't sufficient information to do something better, calls to arithmentic functions tend to end up as calls to their generic versions. However, if you know that your values are possibly bignums, but still at most wordsized, you can use modular arithmetic. See: http://www.sbcl.org/manual/Modulararithmetic.html#Modulararithmetic Example: (defun foo (x y) (declare (type (unsignedbyte 32) x y)) (ldb (byte 32 0) (+ x y))) Cheers,  Nikodemus 