From: Ben Giddings Date: 2003-12-04T01:41:24+09:00 Subject: Re: Attempted roadmap of future instance variables.... David A. Black wrote: > So... for those still reading... here's what I *really* think is being > proposed: > > class A > def m > @var = "hi" # regular instance variable > @_var = "hello" # class-local instance variable > end > end For what it's worth, I don't think this is a good syntax. To me, an underscore is an alphanumeric character. It's special because it is the only non-letter, non-number that can appear in the middle of a variable name: @foo_bar # legal @foo.bar # not the same thing @foo@bar # illegal ... Making @_ a special case is bound to be confusing, because of this. There is also the fact that normally variable names with a leading underscore are a notation that something is internal, and not normally enforced as something different. On the other hand, this is consistent with other instances where the first character of a symbol modifies its behaviour (i.e. if it starts with an uppercase letter, it is a constant). Mainly, I suppose, this just brings back ugly memories of languages that lack truly private variables, so resort to notational hacks like leading underscores. Maybe a leading underscore by itself would be less confusing/distasteful? class A def m @var = "hi" # regular instance variable _var = "hello" # class-local instance variable end end Ben