David A. Black wrote:
Hi --
David A. Black wrote:
Hi --
At least for "def Foo.f1" and "class << Foo" it is not the same one: one holds "A=10" and another -- "A=20".
But only one of them is a singleton class; the other is simply Foo
itselfWhen you do def Foo.m, 'self' is Foo; but when you do class
That's where a slight misunderstanding might have occurred: I was calling "Foo itself" an original singleton class (isn't it? ;-)), and the one created by "class << Foo" -- an anonymous singleton class of Foo (i omitted word "anonymous" from my original reply, sorry).
I realize that we should probably be saying 'virtual class' instead of
'singleton class' (at least, that's what shows up in the error
messages when you try to instantiate one) -- but either way, Foo isn't
oneIt's just a regular class.
David
Hmm, I like "virtual class" much better. I used term "singleton" for describing Foo's class simply to reflect that there's only one instance of class "Class" representing "Foo". Seems like my terminology was misleading.
It's not a very useful usage -- you'd have to call every object in
Ruby a 'singleton' then'Singleton class' has always had the problem that there's also the
Singleton module, so 'singleton class' can also mean a class that
includes that module. 'Virtual class' strikes me as possibly causing
confusion, or false expectations, due to the use of that term for very
different things in other languages. But I don't have a perfect term
Neither Java, nor C++ have term "virtual class", rather "abstract class". "virtual" may be member functions in C++ (or implicitly "non-virtual" in Java if you specify "final" keyword for a method). Also, "virtual" may be inheritance specification in C++.
So at least for those two languages, term "virtual class" is vacant ;-).
for it by any means. (I think there was a discussion about this on
ruby-core or somewhere lately... couldn't find it in a quick search.)David
Gennady.
···
On Wed, 11 Aug 2004, Gennady wrote:
On Wed, 11 Aug 2004, Gennady wrote: