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

David T. Lewis lewis at mail.msen.com
Tue May 10 19:49:34 UTC 2016


I think that one issue is that SmartRefStream only works on positionable
streams, at least for reading. I looked at this a few years ago when I did
RemoteTask because I could not serialize some kinds of objects across an
OS pipe stream. I think this is fixable, but I never actually did anything
about it (I switched to Fuel, which works well for what I was doing).

Dave

> 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