From: matz@... (Yukihiro Matsumoto) Date: 2001-11-24T01:09:42+09:00 Subject: [ruby-talk:26238] Re: OO Singletons and Marshalling (bug?) Hi, In message "[ruby-talk:25963] OO Singletons and Marshalling (bug?)" on 01/11/21, chr_news@gmx.net writes: |the current (i.e. cvs) implementation of the OO Singleton pattern has |no strategy with respect to marshalling - the following script illustrates |the problem. | |--------------- |require 'singleton' |class A | include Singleton |end | |resurrect = Marshal.load(Marshal.dump(A.instance)) |p resurrect == A.instance # => false |--------------- | |The attached script fixes this problem - it is a variation of |the current cvs strategy and implements the following idea |* Ensure that only one instance of the class can be (regularly) | created |* The ``instance'' is created at ``instanciation time'' - i.e. | the first call of #instance |* This behavior is preserved under inheritance I like this one. Can I merge it to the standard distribution, under the terms identical to the rest of Ruby? matz.