From: Tom Sawyer Date: 2002-09-14T05:48:30+09:00 Subject: Re: private variables On Fri, 2002-09-13 at 14:22, William Djaja Tjokroaminata wrote: > I haven't really read the parser yet, but I imagine that after the > detection of keyword "private", the parser/interpreter will call > "rb_define_private_method()" instead of "rb_define_method()". Therefore, > in a similar way, after the detection of the keyword "private", any newly > detected "@var = ..." will not call "rb_iv_set()", but something like > "rb_private_iv_set()" which just simply writes the data in a separate > hash. Now, the "... = @var" case is a little bit more tricky, but I think > it should invoke "rb_private_iv_get()" before searching using > "rb_iv_get()". i see. thanks. so were talking about instance variables being private? ugh, i'm confused (sorry i didn't catch the whole of this thread) arn't instance variable always private? you can only access them through accessor methods. i'm missing somthing here. > > you see that's interesting. that's what i purposed for local variables > > to end writer method ambiguities. ie. does x = 1 mean local variable x = > > 1, or self.x = 1. > > I must be missing something. Why can "x = 1" imply "self.x = 1"? no it can't which is exaclty what i mean becase any other method will imply a self, EXCEPT the writer accessor method, unless of course the local variable is define first. ex- class It attr_accessor :x def seehere x # same as self.x (self is implied) x = 10 # not the same as self.x= x # no longer the same as self.x end end -- tom sawyer, aka transami transami@transami.net