1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-21 11:10:21 +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

@ -6640,24 +6640,34 @@ entry between @var{start} and the end of @var{bitvector}, then return
Modify @var{bitvector} by replacing each element with its negation.
@end deffn
@deffn {Scheme Procedure} bit-set*! bitvector bits bool
@deffnx {C Function} scm_bit_set_star_x (bitvector, bits, bool)
Set entries of @var{bitvector} to @var{bool}, with @var{bits} selecting
the entries to change. The return value is unspecified. Those bits in
the bitvector @var{bits} which are set to one indicate the bits in
@var{bitvector} to set to @var{bool}. @var{bitvector} must be at least
as long as @var{bits}. When @var{bool} is @code{#t} it is as if
@var{bits} is OR'ed into @var{bitvector}, whereas when @var{bool} is
@code{#f} is like an ANDNOT.
@deffn {Scheme Procedure} bitvector-set-bits! bitvector bits
@deffnx {C Function} scm_bit_set_star_x (bitvector, bits)
Set entries of @var{bitvector} to @code{#t}, with @var{bits} selecting
the bits to set. The return value is unspecified. @var{bitvector} must
be at least as long as @var{bits}.
@example
(define bv #*01000010)
(bit-set*! bv #*10010001 #t)
(define bv (bitvector-copy #*11000010))
(bitvector-set-bits! bv #*10010001)
bv
@result{} #*11010011
@end example
@end deffn
@deffn {Scheme Procedure} bitvector-clear-bits! bitvector bits
@deffnx {C Function} scm_bitvector_clear_bits_x (bitvector, bits)
Set entries of @var{bitvector} to @code{#f}, with @var{bits} selecting
the bits to clear. The return value is unspecified. @var{bitvector}
must be at least as long as @var{bits}.
@example
(define bv (bitvector-copy #*11000010))
(bitvector-clear-bits! bv #*10010001)
bv
@result{} #*01000010
@end example
@end deffn
@deffn {Scheme Procedure} bit-count* bitvector bits bool
@deffnx {C Function} scm_bit_count_star (bitvector, bits, bool)
Return a count of how many entries in @var{bitvector} are equal to