[squeak-dev] File in/out class variables

Bert Freudenberg bert at freudenbergs.de
Mon Nov 3 15:44:20 UTC 2008


On 03.11.2008, at 02:10, Herbert König wrote:

> Hi,
>
> is the following class side method a disaster waiting to happen?

Yes.

> readData
> "persistance :-))"
>        |refStream |
>        refStream := ReferenceStream fileNamed: 'HkCalendar.data'.
>        classPool := refStream next.
>        refStream close.
>
>
> or is a class pool just another dictionary?

It is, but the associations in it are also referenced in the  
CompiledMethod's literals. The ref stream will have copies of the  
associations. You would have to recompile all those methods after  
bringing in the classpool.

> BTW it doesn't work but it seemed to do no harm otherwise.
>
> So is there a quick way to store and retrieve all class variables?


This should work:

refStream next keysAndValuesDo: [:k :v | classPool at: k put: v]

- Bert -





More information about the Squeak-dev mailing list