[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "static" declaration

--- Jeremy Hylton <jeremy@alum.mit.edu> wrote:

> Based on my very limited experience with Java, I expect that one
> advantage of knowing all the instance variables of a class is
> distinguishing between local variables and instance variables when
> you're reading code.  In Java method of more than a dozen lines, I
> sometimes have trouble deciding what's an instance variable and
> what's
> a local variable.  In Python, instance variables are accessed as
> attributes of self, so this is always explicit.

Yes, and Ruby prefixes instance variables with "@", providing much the
same benefit. It's the old scoping problem that goes back to Lisp 1.5
and "free" variables. You look at a variable, and you need to be able
to quickly figure out where it came from and what are the consequences
of messing iwth it.

Reginald Braithwaite-Lee
http://www.braithwaite-lee.com/   <-- background information

Do You Yahoo!?
HotJobs - Search Thousands of New Jobs