[squeak-dev] SmartRefStream has no usable Stream interface. Why?

marcel.taeumel Marcel.Taeumel at hpi.de
Tue May 10 10:47:57 UTC 2016


Hi, there!

If you want to serialize an object with the SmartRefStream to support
addition and removal instance variables in classes, you can do this:

obj := Morph new.
stream := SmartRefStream on: #[] writeStream.
stream nextPutObjOnly: obj.
stream close.
blob := stream contents.
objCopy := (SmartRefStream on: blob readStream) next.

Or your can do this, which produces the traditional "file-in format" with a
text header used, for example, when filing out a morph:

obj := Morph new.
stream := SmartRefStream on: (RWBinaryOrTextStream on: '').
stream nextPut: obj.
stream close.
blob := stream contents.
objCopy := (SmartRefStream on: blob readStream asBinaryOrTextStream)
nextAndClose.

This is awkward. It took me some time to figure out that I just cannot use
the regular stream interface, which I can do with ReferenceStream. And
SmartRefStream is just a subclass of it. *sigh*

So, I want to use #nextPut: and #next: just as usual:

obj := Morph new.
stream := SmartRefStream on: #[] writeStream.
stream nextPut: obj.
stream close.
blob := stream contents.
objCopy := (SmartRefStream on: blob readStream) next.

Also, WriteStream DNU #ascii. *sigh*

Best,
Marcel




--
View this message in context: http://forum.world.st/SmartRefStream-has-no-usable-Stream-interface-Why-tp4894185.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.


More information about the Squeak-dev mailing list