#! ruby -Ks

class Foo1
  @@file = "c:/1.tst"

  def self.finalizer_callback
    proc{
        print "finalizer_callback: writing to #{@@file}\n ."
        File.open( @@file , "w" ){|f|
          f.write( 'puts "'+Time.now.to_s+'"')
        }
        print " .. done\n"
    }
  end

  def initialize
    begin
     load @@file
    rescue Exception
    end
    callback = self.class.finalizer_callback
    ObjectSpace.define_finalizer(self, callback)
  end
  
end

########

$foo = Foo1.new

#$foo = nil # ← これがあればOKだが・・

raise
