> TRANS wrote:
...
> BTW, someone asked for use cases. I recalled one yesterday. I used it
> for Infinity. Rather than have two singleton classes, one for positive
> Infinity and another for negative Infinity, I just have one multiton
> class with a negative/positive attribute.
>
> T.


I am not sure if your use case example is a good one. One can make the argument that +/- Infinity should be instances of distinct classes.


Let me also make some remarks about your implementation. The biggest problem is that it doesn't support marshalling (which pretty much boils down to remembering the initializing argument). Also the implementation doesn't preserve the arity  i.e.

class A
def initialize(a,b)
end
include Multiton

p arity(:new) # => 2 but
p arity(:instance) # => -1
end

This is probably just a minor but a ¡Èrobust implementation¡É should support this, i.e. I would expect that
arity(:new) == arity(:instance) # => would return true
for any "Multiton" class.

Last but not least the use of Thread.critical is not suported in the main branch anymore - that is - you should use Mutex#synchronize.


-- 
/Christoph

"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: www.gmx.net/de/go/mailfooter/promail-out