Subject: Re: Improve the efficiency of a simple function
From: (Rob Warnock)
Date: Tue, 23 Jun 2009 23:41:29 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
gugamilare  <> wrote:
| Barry Margolin <> wrote:
| > Also, Common Lisp doesn't do modular arithmetic on UNSIGNED-BYTE, like C
| > does with unsigned.
| Someone correct me if I am wrong, but sbcl seems to be able to unbox
| values in local variables and optimize the use of (unsigned-byte 32).

But *only* when its type inferencer -- plus the type promises your
declarations have made -- can *guarantee* that such optimized use
is valid. As Barry say, it *still* won't do modular arithmetic on
UNSIGNED-BYTE unless you lie to it and then declare (SAFETY 0) or
something. [Or unless you wrap each computation in (LOGAND ... #xffffffff),
or (MOD ... 4294967296) or equiv., whereupon it will feel free to allow
"wraparound" to happen and will cheerfully elide the LOGAND or MOD
from the generated code!]


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607