[Cuis-dev] Class ReferenceStream documentation outdated. Proposed change with fileout

Juan Vuletich juan at jvuletich.org
Thu Aug 19 08:58:14 PDT 2021


On 8/14/2021 2:24 PM, Nicola Mingotti via Cuis-dev wrote:
>
> Hi guys,
>
> I signal you that ReferenceStream class documentation is outdated,
> the example it suggests fails.
> -----
>     rr _ ReferenceStream fileNamed: 'test.obj'.
>     rr nextPut: <your object>.
>     rr close.
> -----
>
> I changed a bit the doc and added 2 convenience methods that can be 
> useful.
>
> ---------- Example
> myObj _ {123. #('foo' 'bar' #(11 23 45)). }.
> ReferenceStream dumpOnFile: ('test1.obj' asFileEntry) object: myObj .
> myObj _ nil.
> myObj  _ ReferenceStream restoreFromFile: ('test1.obj' asFileEntry ).
> myObj print.     "=>  #(123 #('foo' 'bar' #(11 23 45))) "
> ----------
>
> I ask myself. Dump and restore are extremely useful methods. Shouldn't we
> add these methods to Object itself ? [ Maybe they are already there;P 
> and I didn't see. ]
>
>
> bye
> Nicola
>

Hi Nicola,

I just pushed this to GitHub. Note that I slightly modified the code, 
using safer methods for file streams, that ensure: closing the files.

WRT adding helpers to Object, I feel that Object is already too bloated. 
It is even more so in Squeak and other dialects. I wouldn't add more 
stuff to Object unless absolutely needed.

Thanks,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210819/21a27ecd/attachment.htm>


More information about the Cuis-dev mailing list