From: Hal Fulton Date: 2003-12-07T13:47:20+09:00 Subject: Re: Attempted roadmap of future instance variables.... Jesse Tov wrote: [snippage] > I should write about Ruby, in case anyone's still reading, since I have > a proposal. Ruby's naming rules exist for a really good reason: To > make it easy to use differently-scoped variables without ever declaring > anything about them. (Unless Matz says differently, I guess.) Adding a > new kind of variable that requires a declaration, as some have suggested, > would be pretty inconsistent. Adding a new prefix (@_a) would be > consistent, but it adds to the confusion. On the other hand, it would > be easy to search for where it breaks old code. > > After a lot of discussion about this, it seems clear to me that the point > of instance local variables isn't about privacy so much as preventing > accidental collisions. That calls for a solution that makes it easy > to access parents' instance locals, while still differentiating their > namespaces. The proposed use of "namespace" seems a bit syntactically > heavy, though. So, I'm going to propose something analogous to the > case of Foo versus ::Foo: > > @a instance local > @::a parent's instance local > @Foo::a ancestor-named-Foo's instance local > > It doesn't add anything new, since :: already exists for similar things. > It's lightweight and non-restrictive, and seems to blend into the > language pretty well to me. Here's an example: [snip snip] At first glance, I think I like this. > (Please forgive me for delurking in this fashion.) De-lurk more often. You seem to reason well, not to mention spelling and punctuation. :) Of course, someone else may point out why this isn't good. I certainly have not thought it through yet. Hal