From: MikkelFJ Date: 2002-08-16T21:16:31+09:00 Subject: Re: Thought question: Where does "new" come from? > > def Thing.static_show > > puts "Instance scope: @a is >#{@a}<" > > Was that supposed to be "Static scope"? (It is in the output :-) Yeah :-) Several of you have said that instances depend on the value of self. But that is the key of the "problem". What exactly is self. In a class definition there seems to be the class itself, and then there is a default instance which is current value of "self". The class a such does not appear as self, nonetheless it is part of the scope - it is this construct I dubbed the prototype object. class Thing @a = 1 end class < Class (Elaborate on this example) - instance variables in << Thing doesn't appear to be globally shared nor avaible to Thing methods. (But then I'm currently running 1.6.6 and 1.6.8 is changed I hear). > I'm just wondering... I know you mentioned in your last post that you > weren't using standard Ruby terminology. Why not? :-) To be honest because I didn't bother to open the litterature, I was just trying to formulate it to myself. Anyway, the term static is the closest you get to similar constructs in languages like Java and C++. Personally I > don't find the term "static" to be helpful; it seems to obscure the > underlying similarity of the mechanism, and how consistent they are > within and among objects (classes and others). I suppose the same > could be said, in a sense, of the term "class method", since there's > no special term for the singleton methods of other specific types of > object. Anyway, like I said, just wondering :-) The "problem" (if it is a problem) I have with "class method" is that any normally defined method belongs to the class, as opposed to singleton methods that belongs to the instance. Hence I see the normal methods as class methods. The "static" methods belongs to a separate default created instance with the same name as the class. This default instance is statically allocated at the time the class is first defined. Hence the term static method. Mikkel