1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 04:15:36 +02:00

Replace bit-set*! with bitvector-set-bits! / bitvector-clear-bits!

The old name was wonky and hard to read: you almost always pass a
literal as the value to set, so better to make separate functions.

* NEWS: Add entry.
* doc/ref/api-data.texi (Bit Vectors): Update.
* libguile/bitvectors.h:
* libguile/bitvectors.c (scm_bitvector_set_bits_x)
  (scm_bitvector_clear_bits_x): New functions.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_bit_set_star_x): Deprecate.
* module/ice-9/sandbox.scm (mutable-bitvector-bindings): Replace
  bit-set*! with bitvector-set-bits! / bitvector-clear-bits!.
* module/system/vm/frame.scm (available-bindings, compute-killv): Use
  bitvector-set-bits! and bitvector-clear-bits!.
* test-suite/tests/bitvectors.test: Update.
This commit is contained in:
Andy Wingo 2020-04-13 22:06:56 +02:00
parent 06709d77b9
commit ff9979b6bc
9 changed files with 204 additions and 132 deletions

View file

@ -53,22 +53,24 @@
(array-set! bv #t 0)
(pass-if (eqv? (array-ref bv 0) #t)))))
(with-test-prefix "bit-set*!"
(with-test-prefix "bitvector-set-bits!"
(pass-if "#t"
(let ((v (bitvector #t #t #f #f)))
(bit-set*! v #*1010 #t)
(bitvector-set-bits! v #*1010)
(equal? v #*1110)))
(pass-if "#f"
(let ((v (bitvector #t #t #f #f)))
(bit-set*! v #*1010 #f)
(equal? v #*0100)))
(pass-if "#t, shorter"
(let ((v (bitvector #t #t #f #f)))
(bit-set*! v #*101 #t)
(equal? v #*1110)))
(bitvector-set-bits! v #*101)
(equal? v #*1110))))
(with-test-prefix "bitvector-clear-bits!"
(pass-if "#f"
(let ((v (bitvector #t #t #f #f)))
(bitvector-clear-bits! v #*1010)
(equal? v #*0100)))
(pass-if "#f, shorter"
(let ((v (bitvector #t #t #f #f)))
(bit-set*! v #*101 #f)
(bitvector-clear-bits! v #*101)
(equal? v #*0100))))
(with-test-prefix "bitvector-count"