Hi --

"rolo" <rohitlodha / hotwireindia.com> writes:

> Hi
> 
> class A
> 	def instanceMethod
> 	end
> 	def A.classMethod
> 	end
> end
> 
> a = A.new
> 
> def a.objectMethod
> end
> 
> Ruby uses Singleton class for the object a that contains the message table
> with objectMethod in it. Similarly for classMethod.
> 
> Is use of singleton class a specification of ruby or it is implementation
> choice? for example, we can define internal structure for objects in such a
> way that it contains message table.

I know no reason to doubt that it's part of the design of the Ruby
language.  Certainly if you were writing a new implementation of Ruby
it would have to run code that used singleton classes.  If your
implementation didn't use Class objects, but somehow masqueraded
something else as Class objects, I guess that would be OK, as long as
they gave the precise appearance and behavior of Class objects on the
Ruby side.


David

-- 
David A. Black
dblack / wobblini.net