From: "E. Saynatkari" Date: 2006-02-25T07:46:09+09:00 Subject: Re: Private methods - only available to oneself? James Byrne wrote: > E. Saynatkari wrote: > > >> Think of the self.foo call just accessing an object called >> 'self'--sure, it is actually the same object, but you could >> just as well replace 'self' with the external variable name. >> You are still sending a message to an explicit receiver, which >> is not possible in Ruby for any private methods (except for the >> self.foo = 5, where it is required). >> > > Which is why I do not understand the purpose of the distinction between > implicit and explict self. Both cases are simply references. Why does > the interpreter not simply check the reciever object id for === self > when accessing private methods? Where the context cannot determine > intent with resict to assignment (ie foo = "value" is a variable > reference but self.foo = "value" is a call to private method foo=) then > self obviously must be provided, but why must it NOT be provided > otherwise? This makes no sense to me unless it is due a parsing or > other implementation limitation of the interpreter. Conceptually, self.foo= should not require the 'self' part but it is present for the sole benefit of the parser/lexer. So, 'self' is an *external* reference to 'this object'. > If that is the case, well then so be it. What I am interested in > discovering is whether or not their exists a lexical or grammerical > reason for why self is not permitted as an explicit receiver for private > methods except for cases of foo=, where it is then required. > > Regards, > Jim E -- Posted via http://www.ruby-forum.com/.