Tim said:
It has to do with this - which was the context until this message,
where it was snipped out.
``Most of the uses of the classname are redundant. To see that, change
the name of the class. All the uses of the classname (within the
body of the class) that have to change with it are redundant.''
Sorry, I still disagree. Re-using the classname for specific purposes
isn't redundant. *Having* to state something that's obvious from context
is redundant. For example, if you *had* to specify the classname for
context whenever you use a static method would be redundant. If you only
do it to resolve an ambiguity then it's not redundant by any definition
of the word.
I didn't. I wrote it in reply to:
``If so, then we now have *two* ways of doing the *exact same thing* which
to my mind makes the static keyword even *less* attractive.''
The above sentence is quite obviously talking about the proposed
solution in addition to the currently existing solution.
The answer to your question seemed so self-evident I treated it as
rhetorical.
Exactly the same as before. The proposal has nothing whatsoever to do
with that.
The proposed solution is *unnecessary*. It doesn't clarify anything, it
doesn't do anything but use a different word to achieve an end that is
*already achievable* with the current language specification. There has
not been presented a compelling reason for why we should have another
way to do something we can already do now.
A claim *I* never made. I said that you use the classname to specify
context in an ambiguous piece of code. I never said there were only two
ways to resolving this.
There are at least two ways - with or without my proposal. Observing
that there are at least two ways would have been irrelevant to the
proposal.
Huh?
Actually two ways is the current situation - so your argument boils down
to an assertion that the current situation is undesirable ;-)
No, it doesn't. [...]
I /thought/ you were just arguing that having two ways of specifying
a static member was undesirable.
I *am* arguing that, and have been since joining this thread. What part
of my position isn't clear enough for you? The keyword you're proposing
is unnecessary. We can already do what you want by using the classname
to specify context when necessary. The described "static" keyword doest'
do anything that the classname usage can't already do. And we would
still need to use the classname when resolving the static reference from
a different class, so if we had your proposal we would end up with two
ways of achieving one single end built into the language specification.
*THAT* is redundant.
Becasue it can clarifies which variable is being referred to
when the reference is in the same class.
We can *already* do that by using the classname. We don't *need* yet
*another* way to do that.
In this scenario "static" brings nothing new to the table [...]
It deals with the situation where you are distingishing instance
variables, local variables and static variables in the *same* class.
Something that is *already* done by using the name of the class. As I
said, "static" brings nothing _new_ to the table.
This has already been discussed twice. Using the name of the class
in the same class causes refactoring pain,
No, it's not. Eclipse doesn't have a problem, and it's a single, simple
search-and-replace operation for pretty much all editors. Perhaps you
aren't using the right tool?
and leads to reduced
readability when the class name is long.
That, sorry to say, is an opinion and not a fact.
The proposal was never supposed to improve the situation with other
classes.
It is analogous to "this" in that respect.
Except that "this" has a specific purpose that is not available
otherwise. [...]
Not "except" - because that's a different respect.
The "this" keyword has a purpose that cannot be achieved by *any* other
means. How else would you do this?
public class Foo
{
private static Vector instances = new Vector();
public Foo()
{
instances.addElement(this);
}
}
You *can't*. It's impossible without exposing the implementation details
of the Foo class to the outside world.
and you will *still* have to type the classname to provide
context to the compiler. So, in deference to your claiming it's
redundant data, it's actually quite necessary [...]
You should not have to spell out the class name repeatedly in
the class. Doing so is redundant - and it's a maintenance screw-up -
since you open up the possibility of the names getting out of step. You
/should/ be able to say something which says "this class".
You're repeating yourself without supporting your statement. The fact
is, you *don't* _have_ to "spell out the class name" at
*all*....provided you give your static field or method a name *different
from* an instance field/method and a parameter name. [...]
The whole idea of using lint tools in this context is that you add
the "this.", "static." (if available) identifiers at *every* single
location they are used - so you can identify static and instance
variables immediately by looking at them.
Sorry, mate, but *that* is redundancy. You're using a keyword where it's
not necessary.
You do not only add them in
*some* places - that would not produce the same result. You add them
*everywhere* - and use the lint tool to automatically check that they are
used in all the correct places.
You're adding it where it's unnecessary. You're now talking about
altering the language to make it easier for a utility? That's daft.
I don't have to accept it passively. I can request improvements,
that would eliminate this need.
And I'm free to voice my opinion, and I think that this keyword proposal
offers nothing of any value.
IMO, the underlying problem is the existence of a static context -
as opposed to class members and methods. This fudge is being
requested because static methods were always a crude and primitive hack.
That's your opinion. Good luck with that.
Maybe not - but IMO, this thread isn't about doing that.
And all I have read from you has been about trying to change the
language to avoid a style problem. There wouldn't even be a *need* for
the reference if it were clear to the compiler whether you were
referring to a static variable or a method argument. If it were clear
(by using a proper naming convention, for example) then you would *not*
have to tell the compiler "this variable is the static one"....