>>>>> "t" == ts  <decoux / moulon.inra.fr> writes:

t>  Try something like this (this is just an example)

 bad, bad : I've forgotten #[]

t> class WeakRefHash < Hash
t>    def final(a)
t>       lambda { delete(a) }
t>    end

t>    def []=(key, value)
t>       ObjectSpace.define_finalizer(value, final(key))
t>       super(key, value.id)
t>    end

      def [](key)
         v = super(key)
         v = ObjectSpace._id2ref(v) unless v == default
         v
      end

t> end


Guy Decoux