[Glass] How to properly write bytes objects into binary streams?

Martin McClure via Glass glass at lists.gemtalksystems.com
Wed Sep 3 13:07:29 PDT 2014

On 09/03/2014 12:26 PM, Mariano Martinez Peck wrote:
> On Wed, Sep 3, 2014 at 4:10 PM, Dale Henrichs
> <dale.henrichs at gemtalksystems.com
> <mailto:dale.henrichs at gemtalksystems.com>> wrote:
>     My point is that LargeIntegers are not polymorphic byte-objects (no
>     methods for accessing the bytes for a LargeInteger) ... in GemStone
> OK. Thanks. Point taken. I could make a special serialization for them.
> But I was hoping to find a general way for all the other guys. These are
> the problematic ones:

#_basicAt: and #_basicAt:put: do work to access the bytes of large 
integers (and I think all byte objects).

The trick is to create an instance of these class classes. For 
LargeInteger, for instance, this is currently quite restricted. The best 
I've come up with so far is to create one the correct size like this:

| size int1 int2|
size := <size in bytes you want>
int1 := (2 raisedToInteger: (size - 4 * 8)) - 1.
"int1 is the right size, but immutable"
int2 := int1 copy.
"int2 is mutable, and can be modified via #_basicAt:put:"



More information about the Glass mailing list