[squeak-dev] File in/out class variables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] File in/out class variables

Herbert König
Hi,

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

readData
"persistance :-))"
        |refStream |
        refStream := ReferenceStream fileNamed: 'HkCalendar.data'.
        classPool := refStream next.
        refStream close.


or is a class pool just another dictionary?

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?


Thanks,

Herbert


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] File in/out class variables

Bert Freudenberg
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 -



Reply | Threaded
Open this post in threaded view
|

Re[2]: [squeak-dev] File in/out class variables

Herbert König
Hello Bert,

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

Thanks, that makes it understandable.

Herbert                            mailto:[hidden email]