From: Mark Sparshatt Date: 2004-04-03T08:30:09+09:00 Subject: Re: Variable names David King Landrith wrote: > > On Apr 2, 2004, at 5:22 PM, Jim Weirich wrote: > >> >> David King Landrith said: >> >>> Let me restate the question: >>> >>> Whenever a method is called on an object, one and only one symbol is >>> used to represent the object. >> >> >> That statement is incorrect. > > > Fair enough. Does this work? > > Whenever a method is called on an object, one and only one expression > or symbol has been resolved to > used to represent the object. > > And so: > > Is there any way to determine which symbol was representing the > expression or symbol at the time that the method was invoked? > > You'll forgive me if I feel like I'm playing twenty questions here. > Perhaps I should be asking: There seems to be some "thing" that the > interpreter determines refers to an object, and there can only be one > of these per method that is invoked. How would we describe this "thing"? > This thing is a reference to the receiving object. you can use self#id to find out this reference but you can't go from that to the variable or expression that was origionaly used. >> Simple answer: NO > > > I can see that this is also the answer to the restated question I ask > above. > > Just out of curiosity: At what point does the interpreter discard the > expression that it been evaluated to represent the object? Presumably as soon as it has been evaluated. you want to define a method so that this works class X def meth() p self.magic end end x = X.new x.meth #=> x the problem is this is the moral equivelent of def meth(self) p self.magic end x = x.new meth(x) #=> x within meth it just knows there is an object called self, it has no knowledge of the fact that elsewhere in the program this object is reffered to as x. -- Mark Sparshatt