From: dblack@... Date: 2006-01-27T02:35:52+09:00 Subject: Re: Class is object? :very_sleepy Hi -- On Fri, 27 Jan 2006, Lionel Thiry wrote: >> What I would really like is a better metaphore for class! >> Thanks! > > Objects generally don't like to hold their methods themselves, that's > why they ask for other objects, called classes, to hold them. Those > objects are smart and they gather the burden of methods with other > objects, some of them are called modules, while the others are classes. > > Sometimes, an object like to hold a method without help. It wants to do > it itself, alone, as if it was a singleton, the unique object of its > kind in the universe. That's why those kind of methods are called > "singleton methods". > > In ruby, even singleton methods are not truly hold by the object itself, > even if all goes as if it was. A singleton method is hold by a special > object whose name is still hard to define (singleton class, eigenclass, > metaclass, etc...). (Singleton class was the last term I heard Matz say he was using :-) The point about objects not holding methods is so important. People sometimes talk about "adding methods to objects", and then get tripped up about method lookup order. It's more a matter of the object meandering through classes and modules, in a certain order, trying to find a match for a message it's received. David -- David A. Black dblack@wobblini.net "Ruby for Rails", from Manning Publications, coming May 1, 2006! http://www.manning.com/books/black