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

Nicola Mingotti nmingotti at gmail.com
Fri Aug 20 06:48:11 PDT 2021



On 8/19/21 5:58 PM, Juan Vuletich via Cuis-dev wrote:
> 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
>
Ok Juan, thanks.

during the long Debian upgrade i red almost all the chapter 6-Objects of 
Lalonde book vol-1.
i learnt Object has already "printOn:", so it actually has already 
dump/restore capabilities.
It is not "circle-safe" but that is another story. No need to add more 
methods, agreed. The
basic capability is there.

bye
Nicola















-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210820/047d7734/attachment.htm>


More information about the Cuis-dev mailing list