From: Logan Capaldo Date: 2007-09-02T05:14:51+09:00 Subject: Re: Singleton Modules rather than Singleton Classes On 9/1/07, Trans wrote: > This recently came up in the thread entitled "Python-style > Decorators", so I thought it a fair idea to "formally" put it before > the Ruby community. Here's the deal... > > Singleton classes already have more in common with modules than > classes by the very behaviors that distinguish a module from a class -- > they cannot be instantiated and they can not be inherited. So why > exactly do we deem them classes at all? If instead we took them to be > actual modules, and used as such, it would open up some really nice > possibilities. For example: > Counter proposal: remove singleton classes all together in favor of simply having singleton methods. The useful facility of a singleton class is that it allows you to have per-object methods (singleton methods). Class and module are both misnomers for the "thing that acts as a place to store singleton methods." By eliminating the visibility of this implementation detail, it allows for other implementations to be experimented with. The more you pin down how singleton methods are implemented, and the more you start doing things with details of that implementation the hard it becomes to have flexibility in that implementation. This also removes the need to justify referring to them as classes, and the false expectations this creates. My 2cents.. > >