[racket] Best typed/racket representation for bitfield of width 125?

From: Greg Hendershott (greghendershott at gmail.com)
Date: Thu Sep 4 14:41:31 EDT 2014

Although I haven't tried data/bit-vector in Typed Racket, could you do
something like the following?

#lang typed/racket

(require/typed data/bit-vector
  [#:opaque BitVector bit-vector?]
  [make-bit-vector (-> Index BitVector)]
  ... TO-DO ...)

(define bv (make-bit-vector 125))


On Thu, Sep 4, 2014 at 1:45 PM, John Clements <johnbclements at gmail.com> wrote:
> I want to represent a bitfield of 125 bits, using typed racket. I’ll be
> combining them using bitwise operations, and checking for zero-ness. I think
> that’s about it.
>
> I could just use type Integer, but it seems like that would impose
> additional checking, since the type system doesn’t know the size.  In
> untyped racket I used a vector of four integers in the range 0-2^32, but
> those don’t fit in typed Racket’s “Fixnum” because it uses a signed
> representation (and indeed, untyped racket may have been falling prey to the
> same problem. Perhaps I should break it up into four integers in the range
> 0-2^31? That seems weird, but maybe that’s my best choice? Or… I could use a
> byte string.
>
> Apologies if I’m missing something in the docs, here; I’ve spent a few
> minutes searching, without turning anything up.
>
> Thanks for any advice,
>
> John
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>


Posted on the users mailing list.