--- Begin Message ---
Dear Pharo experts,

I am wondering if there is a good way to deal with singleton objects
whose value needs to be updated following changes in the code that
initializes it.

Following the model of many examples in Pharo itself, I have defined a
singleton class with a uniqueInstance method for accessing (and creating
if necessary) the single instance, and a method "reset" marked as a
script to set the uniqueInstance back to nil when required, i.e. after
source code changes make the prior value inappropriate.

This works very well, as long as I don't forget to do the reset, which
has already caused me a few hours of debugging time. Worse, suppose
someone else is using my project in progress, pulling changes from my
GitHub repo once per week. That person cannot know if the latest changes
require a singleton reset. More importantly, users shouldn't have to
know about such internal details at all.

So is there a way to do the reset automatically whenever a new version
of my package is loaded into an image?

Thanks in advance,
  Konrad.


--- End Message ---

Reply via email to