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

Chris Muller asqueaker at gmail.com
Tue May 10 17:47:00 UTC 2016


I feel your pain!   :)

I wouldn't mind ReferenceStream to just be upgraded to be "smart" and
then deprecate SmartRefStream.  Keeping the nice API of
ReferenceStream, of course.

If Smalltalk is capable to let volatile memory withstand class-schema
changes, I see no reason it should suddenly fail just to thaw cold
storage objects into a newer image..  And no instvar mapping "specs"
are needed, just map them by name...


On Tue, May 10, 2016 at 5:47 AM, marcel.taeumel <Marcel.Taeumel at hpi.de> wrote:
> 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