From: Joel VanderWerf Date: 2005-10-18T12:54:13+09:00 Subject: Re: [ANN] BitStruct Morgan wrote: > [I really wish I knew how to make eudora do attribution lines > automatically...] > > Joel VanderWerf wrote: > >> (Exerpt from the docs at the project page, >> http://redshift.sourceforge.net/bit-struct/.) >> >> = BitStruct > > > > Looks pretty interesting. I do have one question though. > > I've got a project I've been thinking about doing a project that would > benefit from the use of arrays of two-bit unsigned integers, of > unknown-at-time-of-coding but probably large size. Which will also > need to be shoved across sockets occaisionally. Is there a convenient > way to make a structure like this using BitStruct? Not yet. I haven't needed variable sized arrays of anything except chars. For now, if you want to get something working quickly, you're probably better off with String#[] (i.e. slice) and some bit arithmetic (which is just what BitStruct does anyway). Or use a C extension. (You can take a look at unsigned-field.rb for how to set up masks and so on, but it's nothing special.) Maybe someone else can pipe up if there is a way to do this with Ruby/DL or something else? It would be great if ruby had a built-in method (or a standard lib extension) for doing bit-wise slice operations (and other bit-oriented string operations)... -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407