On Tue, May 9, 2017 at 11:53 AM, Peter Lane
<
xxxxxx@peterlane.info
>
wrote:
Thanks for doing the work. I've rewritten this as:
(cond-expand
;(chibi (include-shared "bit")
;(include "chibi-core.scm"))
((library (rnrs arithmetic bitwise))
(import (only (rnrs arithmetic bitwise)
bitwise-not bitwise-and bitwise-ior bitwise-xor
bitwise-bit-count bitwise-length))
(import (rename (only (rnrs arithmetic bitwise)
bitwise-arithmetic-shift bitwise-length)
(bitwise-arithmetic-shift arithmetic-shift)
(bitwise-length integer-length)))
(define (bit-count i) ; Note, negative case different to R6RS bitwise-bit-count
(if (>= i 0)
(bitwise-bit-count i)
(bitwise-bit-count (bitwise-not i)))))
(gauche
(import (only (gauche base)
integer-length))
(import (rename (only (gauche base)
lognot logand logior logxor ash)
(lognot bitwise-not)
(logand bitwise-and)
(logior bitwise-ior)
(logxor bitwise-xor)
(ash arithmetic-shift))))
(else (include "bitwise-core.scm")))
on the assumption that compiler inlining and such is more likely to work after import-with-renaming than after defining an equivalent function.
--
John Cowan
http://vrici.lojban.org/~cowan
xxxxxx@ccil.org
Raffiniert ist der Herrgott, aber boshaft ist er nicht.
--Albert Einstein