Goods: Problems with characters and primitives

Avi Bryant avi at beta4.com
Sun Jul 11 17:52:20 UTC 2004


On Jul 11, 2004, at 3:22 AM, Adrian Lienhard wrote:

> Hi,
>
> I've come across a problem concerning storing characters in goods and 
> another issue concerning primitives:
>
> When you store a character in the DB and then load it again, #= will 
> not return true for the same character. The problem is that  the goods 
> client creates the character object on its own when loading in again 
> without taking the unique object from the character table which leads 
> to the problem that the primitive in #= (which tests characters on 
> object identity) fails. My current solution is to implement the class 
> CharacterDescriptor with:
> objectFromStream: aStream
> 	^Character value: (super objectFromStream: aStream) hash

Thanks, I didn't realize Character was a flyweight class.  I'll 
incorporate that change.  But it's probably safer to use #asciiValue 
than #hash.

Alternatively, we could make Character an immediate type (from a GOODS 
POV) instead of a reference type - GOODS has lots more bits to tag with 
than the Squeak VM does ;).  If you're storing large numbers of 
characters outside of strings this might be useful.  What's your use 
case?

> Another problem I encountered was the following: When writing data 
> from the DB on a stream the primitive in WriteStream>>nextPut: failed. 
> I assume the problem is that there was a goods proxy object passed as 
> parameter. Since with normal message sends the proxy always resolves 
> correctly to the actual object by the DNU trick - but this fails with 
> primitives. For the moment, I just send #yourself at the right place 
> to the objects before passing them to the stream but I don't have a 
> general solution. Anyone?

Hm, that's an interesting one.  This should only happen with 
Characters, right?  Since the only time #nextPut: is checking the type 
is when the stream is backed by a String, and it's checking for 
Character.  If we make Characters immediate, they'll never be proxied 
and so this won't happen.  Or am I missing something?

Avi




More information about the Squeak-dev mailing list