From: William Djaja Tjokroaminata Date: 2002-09-14T05:42:44+09:00 Subject: Re: private variables Kent Dahl wrote: > I'd prefer having something explicit like: > private_variables :some, :privvy, :vars, :listed, :here > making @some, @privvy, @vars, @listed and @here private in that class. > And who knows, perhaps there is some magic tricks to be learned if > privateness can be dynamic and delayed. (I.e. define class, methods and > make instances, then pull a class_eval { private_variables :somevar }) I am not an expert in Ruby parser/interpreter at all (let alone computer science), but to me this seems perfectly doable. I.e., after the detection of keyword "private_variables", all public variables in the list are moved from the current (public) instance variable hash to the private instance variable hash. And then writing and reading the instance variables are like in my other post. > IIRC, neither of $ or @ are used as operators, but % is modulus in Ruby. > I can't think of any case where it would not be backwards compatible, > but I think it looks confusing: > a = b%c # b modulus c > a = b %c # call method b with one argument; private variable c > But then, perhaps we have enough training dealing with this confusion > due to things like a +5 versus a+5... Well, "%" is also used in Perl as a modulus operator, and its use with variables is fine there. Like you have written above, we can make the rule. But probably people should write code in an explict way... Regards, Bill