Ben Giddings <ben / thingmagic.com> wrote:
> On Tue July 29 2003 11:10 am, ts wrote:
> >  the instance is a class instance variable, because the class Stats will be
> >  not removed, the instance will be marked when the GC run
> 
> Ah, how cool.  I have never (knowingly) encountered a class instance variable 
> before, especially not one that contained an instance of itself.  Now that I 
> take a closer look it all makes good sense, and does exactly what I want.  
> When I found out that classes in ruby are instances of the "Class" type, I 
> knew that would add all kinds of flexibility, but I didn't anticipate this 
> use.

Just another warning. I don't know how to control the instance
creation time of singletons in Ruby. I would guess it's lazy
initialisation. This could introduce problems when comparing memory
snapshots. You gonna get differences where you don't expect them.

So although you are happy that the GC don't kill your singleton, I
would like to know: Is there a standard way to remove a singleton in
Ruby?

(---- Off topic remark: ---- snip >-----
I've seen some discussion about Ruby IDEs stating that you'll need an
image based ruby IDE to implement a powerful debugging environment. In
an image based IDE all objects building the IDE could be made
persistent. You can store the complete state of the IDE including
windows and running processes. Think about storing the state of IRB
and you have an image based system.

Singletons will cause problems in such an image based system:
  http://c2.com/cgi/wiki?SmalltalkSingletonProblem

Not only IDEs benefit from storing the state of processes, a PC with 
powermanagement or a database needs to store the state of running
processes, too.
------)

Cheers
Sascha