----- Original Message -----
From: "Mark Wilson" <mwilson13 / cox.net>
1. I don't see the practical problem with having singleton classes and
I do see benefits to having a direct implementation of a useful design
pattern.
----------------------------
As far as I understand it (though I could easily be wrong; those are
dangerous words! :), singleton classes have nothing to do with the Singleton
mixin...
<looking it up>
Wrong again. :) Module Singleton is written in Ruby, using the singleton
class of the mixed-into-class.
Hmmm...
It certainly seems possible to write the Singleton module in C, as part of
the interpreter, but I don't think you would be able to write it directly in
Ruby with what I am talking about.
Now THAT is a good reason for singleton classes. (This is not to say I'm
sold on the idea, mind you, but it is a good reason.)
----------------------------
2. I don't see a sound basis for saying that Class.new is broken.
----------------------------
Well, I said that right after Guy's code, which illustrated the problem.
Class.new returns an object (which we call a "class object") whose klass
pointer is Class. This is fine if you don't allow anyone to subclass Class
(which is the case in the standard Ruby). However, if you allow Class to be
subclassed (as Guy did) by some other class (let's call it A), then A.new
(which calls Class.new) creates a "class object" whose class pointer is
Class. I'm saying the klass pointer should be *self*, which is A in this
case, and Class in every case happening on a computer other than Guy's.
<chuckle>
True, this isn't a problem if you don't allow Class to be subclassed;
Class.new is only broken if you remove the checks which prevent you from
noticing it's broken... er, so to speak.
----------------------------
3. I don't see why the kind_of? method is any more preferable to the
class method.
----------------------------
Well... it allows subclasses of the intended class to pass the type-check.
Granted, they're both not very good things to do, but in the sense that one
is bad, it seems the other is worse. This is *not* something I feel
strongly about; they are both to be avoided when possible.
----------------------------
4. Can't one come to understand language design principles by
increasing one's understanding of an implementation like Ruby?
----------------------------
Isn't that what I'm doing? :)
I'm having a conversation I could not have had last week.
Chris